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

Cannot parse REFERENCES clause of CREATE TABLE in mysql 5.6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 0.2
    • 0.1
    • mysql-connector

      I'm getting this odd behavior with the app/mysql version i'm using 5.6 (https://github.com/openshift/mysql) and using the ticket monster application. I'm getting stack traces like this:

      2016-05-05 20:46:52,685 - ERROR [WorkerSourceTask-ticketmonster-connector-0:TableConverters@111] - Error parsing DDL statement and updating tables: CREATE TABLE IF NOT EXISTS help_r
      elation ( help_topic_id int unsigned not null references help_topic, help_keyword_id  int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) e
      ngine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation';
      io.debezium.text.ParsingException: Expecting '(' at line 1, column 101 but found ',': eferences help_topic ===>> , help_keyword_id  i
              at io.debezium.text.TokenStream.consume(TokenStream.java:693)
              at io.debezium.connector.mysql.MySqlDdlParser.parseColumnNameList(MySqlDdlParser.java:983)
              at io.debezium.connector.mysql.MySqlDdlParser.parseReferenceDefinition(MySqlDdlParser.java:581)
              at io.debezium.connector.mysql.MySqlDdlParser.parseColumnDefinition(MySqlDdlParser.java:526)
              at io.debezium.connector.mysql.MySqlDdlParser.parseCreateColumn(MySqlDdlParser.java:437)
              at io.debezium.connector.mysql.MySqlDdlParser.parseCreateDefinition(MySqlDdlParser.java:427)
              at io.debezium.connector.mysql.MySqlDdlParser.parseCreateDefinitionList(MySqlDdlParser.java:353)
              at io.debezium.connector.mysql.MySqlDdlParser.parseCreateTable(MySqlDdlParser.java:183)
              at io.debezium.connector.mysql.MySqlDdlParser.parseCreate(MySqlDdlParser.java:133)
              at io.debezium.connector.mysql.MySqlDdlParser.parseNextStatement(MySqlDdlParser.java:116)
              at io.debezium.relational.ddl.DdlParser.parse(DdlParser.java:269)
              at io.debezium.relational.ddl.DdlParser.parse(DdlParser.java:250)
      

      But this kinda doesn't make any sense.. from the code we expect a '(" opening brace for the column name, but as the stack trace indicates, the statement doesn't have an parens..

          protected List<String> parseColumnNameList(Marker start) {
              List<String> names = new ArrayList<>();
              tokens.consume('(');
              names.add(tokens.consume());
              while (tokens.canConsume(',')) {
                  names.add(tokens.consume());
              }
              tokens.consume(')');
              return names;
          }
      

      And seems the parsing is correct based on the mysql REFERENCES clause:

      https://dev.mysql.com/doc/refman/5.6/en/create-table.html

      reference_definition:
          REFERENCES tbl_name (index_col_name,...)
            [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
            [ON DELETE reference_option]
            [ON UPDATE reference_option]
      

      Not sure if this is a bug in mysql or how this statement got created.

              rhauch Randall Hauch (Inactive)
              ceposta_jira christian posta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: