You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/10 02:50:14 UTC

[GitHub] [shardingsphere] Lucas-307 commented on a change in pull request #7725: Fix mysql binlog type decode

Lucas-307 commented on a change in pull request #7725:
URL: https://github.com/apache/shardingsphere/pull/7725#discussion_r502736666



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
##########
@@ -31,18 +31,32 @@
     
     @Override
     public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) {
-        switch (MySQLColumnType.valueOf(columnDef.getColumnMeta() >> 8)) {
+        int type = columnDef.getColumnMeta() >> 8;
+        int length = columnDef.getColumnMeta() & 0xff;
+        // unpack type & length, see https://bugs.mysql.com/bug.php?id=37426.
+        if ((type & 0x30) != 0x30) {
+            length += ((type & 0x30) ^ 0x30) << 4;
+            type |= 0x30;
+        }
+        switch (MySQLColumnType.valueOf(type)) {
             case MYSQL_TYPE_ENUM:
-                return readEnumValue(columnDef.getColumnMeta() & 0xff, payload);
+                return readEnumValue(length, payload);
             case MYSQL_TYPE_SET:
                 return payload.getByteBuf().readByte();
             case MYSQL_TYPE_STRING:
-                return payload.readStringFix(payload.getByteBuf().readUnsignedByte());
+                return payload.readStringFix(readActualLength(payload, length));

Review comment:
       please make sure args is in the same order.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org