zendesk / maxwell

Maxwell's daemon, a mysql-to-json kafka producer
https://maxwells-daemon.io/
Other
4.04k stars 1.01k forks source link

Maxwell shutdown on encountering 'year' datatype #66

Closed akshayi1 closed 9 years ago

akshayi1 commented 9 years ago

Similar to #64 and #65, maxwell barfs and fails when it encounters a year datatype.

bin/maxwell --user='root' --password='root' --host='127.0.0.1' --producer=stdout
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
23:29:28,708 INFO  Maxwell - Maxwell is booting, starting at BinlogPosition[mysql-logs.000003:6982]
23:29:28,710 DEBUG SchemaStore - looking to restore schema at target position BinlogPosition[mysql-logs.000003:6982]
23:29:28,711 INFO  SchemaStore - Restoring schema id 7 (last modified at BinlogPosition[mysql-logs.000003:6982])
23:29:28,753 INFO  TransportImpl - connecting to host: 127.0.0.1, port: 3306
23:29:28,785 INFO  TransportImpl - connected to host: 127.0.0.1, port: 3306, context: AbstractTransport.Context[threadId=25,scramble=@/f8$H"l|J=4*t,{KCN?,protocolVersion=10,serverHost=127.0.0.1,serverPort=3306,serverStatus=2,serverCollation=8,serverVersion=5.6.24-0ubuntu2-log,serverCapabilities=63487]
23:29:28,785 INFO  AuthenticatorImpl - start to login, user: root, host: 127.0.0.1, port: 3306
23:29:28,792 INFO  AuthenticatorImpl - login successfully, user: root, detail: OKPacket[packetMarker=0,affectedRows=0,insertId=0,serverStatus=2,warningCount=0,message=<null>]
23:29:28,974 DEBUG SchemaChange - SQL_PARSE <- "create table max_test4(dt datetime, dt_y year(4))"
line 1:45 mismatched input '(' expecting {',', ')', AUTO_INCREMENT, COLUMN_FORMAT, COMMENT, DEFAULT, NOT, NULL, ON, PRIMARY, STORAGE, UNIQUE}
line 1:48 extraneous input ')' expecting {<EOF>, AUTO_INCREMENT, AVG_ROW_LENGTH, CHARACTER, CHARSET, CHECKSUM, COLLATE, COMMENT, CONNECTION, DATA, DEFAULT, DELAY_KEY_WRITE, ENGINE, INDEX, INSERT_METHOD, KEY_BLOCK_SIZE, MAX_ROWS, MIN_ROWS, PACK_KEYS, PASSWORD, ROW_FORMAT, TABLESPACE, UNION}
23:29:29,065 ERROR MysqlParserListener - (column_definition (name (id dt_y)) (data_type (generic_type year)) ( 4)
23:29:29,065 ERROR SchemaChange - Error parsing SQL: 'create table max_test4(dt datetime, dt_y year(4))'
com.zendesk.maxwell.schema.ddl.MaxwellSQLSyntaxError: (
at com.zendesk.maxwell.schema.ddl.MysqlParserListener.visitErrorNode(MysqlParserListener.java:85)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:41)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
at com.zendesk.maxwell.schema.ddl.SchemaChange.parse(SchemaChange.java:65)
at com.zendesk.maxwell.MaxwellParser.processQueryEvent(MaxwellParser.java:206)
at com.zendesk.maxwell.MaxwellParser.getEvent(MaxwellParser.java:192)
at com.zendesk.maxwell.MaxwellParser.getEvent(MaxwellParser.java:198)
at com.zendesk.maxwell.MaxwellParser.run(MaxwellParser.java:98)
at com.zendesk.maxwell.Maxwell.run(Maxwell.java:69)
at com.zendesk.maxwell.Maxwell.main(Maxwell.java:75)

And just like #64 and #65, re-running Maxwell does not work and produces the same text as above and exits. I will need to purge and delete again for this to work.

akshayi1 commented 9 years ago

For this, a bit of a cheat, but I tried:

ColumnDef.java

case "year":
case "year(2)":
case "year(4)":
    return new YearColumnDef(tableName, name, type, pos);

And this did not work too.

osheroff commented 9 years ago

yeah, you'd need to start with the SQL-parser, which is in src/main/antlr4/imports/column_definitions.g4

akshayi1 commented 9 years ago

68 fixes this. Thanks!