Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-2080

Unable to parse MySQL ALTER statement with named primary key

XMLWordPrintable

    • Hide

      Create a table:

      CREATE TABLE IF NOT EXISTS tasks_gon (
          task_id INT,
          title VARCHAR(255) NOT NULL
      );
      

      That statement succeeds in MySQL and Debezium is able to process it.

      Add primary key using backquote:

      alter table `tasks_gon`
          add primary key `tasks_gon_task_id_primary`(`task_id`);
      

      That statement succeeds in MySQL but Debezium fails to parse.

      That kind of statements are generated by Laravel, a PHP framework for DB access. See https://laravel.com/docs/7.x/migrations#creating-tables

      Thank you!

      Show
      Create a table: CREATE TABLE IF NOT EXISTS tasks_gon ( task_id INT, title VARCHAR(255) NOT NULL ); That statement succeeds in MySQL and Debezium is able to process it. Add primary key using backquote: alter table `tasks_gon` add primary key `tasks_gon_task_id_primary`(`task_id`); That statement succeeds in MySQL but Debezium fails to parse. That kind of statements are generated by Laravel, a PHP framework for DB access. See https://laravel.com/docs/7.x/migrations#creating-tables Thank you!

      Error when parsing a MySQL statement with backquote character `

      connect      | 2020-05-14 13:35:02,397 WARN   MySQL|virtatest|binlog  Ignoring unparseable DDL statement 'alter table `tasks_gon` add primary key `tasks_gon_task_id_primary`(`task_id`)': {}   [io.debezium.connector.mysql.MySqlSchema]
      connect      | io.debezium.text.ParsingException: no viable alternative at input 'alter table `tasks_gon` add primary key `tasks_gon_task_id_primary`'
      connect      | 	at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:40)
      connect      | 	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
      connect      | 	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
      connect      | 	at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
      connect      | 	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
      connect      | 	at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1121)
      connect      | 	at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:849)
      connect      | 	at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:68)
      connect      | 	at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:41)
      connect      | 	at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:80)
      connect      | 	at io.debezium.connector.mysql.MySqlSchema.applyDdl(MySqlSchema.java:308)
      connect      | 	at io.debezium.connector.mysql.BinlogReader.handleQueryEvent(BinlogReader.java:729)
      connect      | 	at io.debezium.connector.mysql.BinlogReader.handleEvent(BinlogReader.java:519)
      connect      | 	at com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1095)
      connect      | 	at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:943)
      connect      | 	at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:580)
      connect      | 	at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:825)
      connect      | 	at java.base/java.lang.Thread.run(Thread.java:834)
      connect      | Caused by: org.antlr.v4.runtime.NoViableAltException
      connect      | 	at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
      connect      | 	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
      connect      | 	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
      connect      | 	at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:923)
      connect      | 	... 12 more
      
      

              jpechane Jiri Pechanec
              gborobio73 Gonzalo Borobio (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: