{"record":{"id":"d62243446e8b2d31","repo":"apache/shardingsphere","slug":"mysql-enum-meta-in-binlog-only-include-value-1-or","errorCode":null,"errorMessage":"MySQL Enum meta in binlog only include value 1 or 2, but actual is %s","messagePattern":"MySQL Enum meta in binlog only include value 1 or 2, but actual is (.+?)","errorType":"exception","errorClass":"UnsupportedSQLOperationException","httpStatus":null,"severity":"error","filePath":"database/protocol/dialect/mysql/src/main/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java","lineNumber":65,"sourceCode":"            case STRING:\n                return new MySQLBinaryString(payload.readStringFixByBytes(readActualLength(length, payload)));\n            default:\n                throw new UnsupportedSQLOperationException(MySQLBinaryColumnType.valueOf(type).toString());\n        }\n    }\n    \n    private int readActualLength(final int length, final MySQLPacketPayload payload) {\n        return length < 256 ? payload.getByteBuf().readUnsignedByte() : payload.getByteBuf().readUnsignedShortLE();\n    }\n    \n    private Serializable readEnumValue(final int meta, final MySQLPacketPayload payload) {\n        switch (meta) {\n            case 1:\n                return payload.readInt1();\n            case 2:\n                return payload.readInt2();\n            default:\n                throw new UnsupportedSQLOperationException(String.format(\"MySQL Enum meta in binlog only include value 1 or 2, but actual is %s\", meta));\n        }\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/database/protocol/dialect/mysql/src/main/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java#L47-L69","documentation":"Thrown while decoding a MySQL ENUM column from a binlog row event: ENUM storage meta must be 1 or 2 (byte or word index into the enum definition). Any other value throws UnsupportedSQLOperationException because the enum ordinal cannot be read.","triggerScenarios":"Calling readEnumValue() with meta other than 1 or 2 when a row event's string column is classified as ENUM in MySQLStringBinlogProtocolValue.","commonSituations":"MariaDB/MySQL fork differences in string-type sub-encodings; a misread type byte (column classified as ENUM when it is SET or another string subtype) due to reader desync or a stale TABLE_MAP; enum columns after ALTER TABLE with many values.","solutions":["Decode the TABLE_MAP event for the table and confirm the column's real type/meta bytes match ENUM with width 1 or 2","Confirm the server flavor/version is MySQL with a supported binlog format (ROW)","Restart/resync the binlog subscription so table metadata is rebuilt from the current TABLE_MAP","Report the meta value and server version upstream if a genuine new encoding is found"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"int meta = columnDefinition.getColumnMeta();\nif (columnDefinition.isEnum() && meta != 1 && meta != 2) {\n    // classification/meta mismatch: re-read the TABLE_MAP for this table before decoding enum columns\n    refreshTableMap(event.getTableId());\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    value = readEnumValue(meta, payload);\n} catch (UnsupportedSQLOperationException ex) {\n    // enum width must be 1 or 2: log table id + meta, resync the table map, and skip the event\n    resyncAndSkip(eventHeader, ex);\n}","preventionTips":["Re-resolve TABLE_MAP entries after schema changes on enum-containing tables","Confirm MySQL vs MariaDB string-type encodings before ingesting mixed-fleet binlogs"],"tags":["mysql","binlog","enum","cdc","metadata-mismatch"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}