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

CREATE TABLE query is giving parsing exception

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 1.0.0.Final, 1.1.0.Final
    • 1.2.0.CR1
    • mysql-connector
    • None
    • Hide

      Add a testcase to MySqlAntlrDdlParserTest.java:

      @Test
          @FixFor("DBZ-Ritesh Singh")
          public void shouldExceptChracterinCreateTable()
          {
              String ddl = "CREATE TABLE `NTFCTN_TEMPLATE_DATA` (\n" +
                      " `RECORDID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `DATEADDED` DATETIME NOT NULL,\n" +
                      " `DATEMODIFIED` DATETIME NOT NULL,\n" +
                      " `TEMPLATEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `LOCALEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `OWNERSITEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `ENABLE` CHARACTER(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `TASKENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `ROLEROUTINGENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `NAME` VARCHAR(1000) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `DATA` LONGTEXT COLLATE utf8_unicode_ci NOT NULL,\n" +
                      "  PRIMARY KEY (`RECORDID`),\n" +
                      "  UNIQUE KEY `NTFNDATA_TEMPID_LOCID_OWNID_UQ` (`TEMPLATEID`,`LOCALEID`,`OWNERSITEID`)\n" +
                  ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
      
              parser.parse(ddl, tables);
              assertThat(((MySqlAntlrDdlParser) parser).getParsingExceptionsFromWalker().size()).isEqualTo(0);
              assertThat(tables.size()).isEqualTo(1);
          }
      

      Run the testcase.

      Show
      Add a testcase to MySqlAntlrDdlParserTest.java: @Test @FixFor( "DBZ-Ritesh Singh" ) public void shouldExceptChracterinCreateTable() { String ddl = "CREATE TABLE `NTFCTN_TEMPLATE_DATA` (\n" + " `RECORDID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" + " `DATEADDED` DATETIME NOT NULL,\n" + " `DATEMODIFIED` DATETIME NOT NULL,\n" + " `TEMPLATEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" + " `LOCALEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" + " `OWNERSITEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" + " `ENABLE` CHARACTER(1) COLLATE utf8_unicode_ci NOT NULL,\n" + " `TASKENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" + " `ROLEROUTINGENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" + " `NAME` VARCHAR(1000) COLLATE utf8_unicode_ci NOT NULL,\n" + " `DATA` LONGTEXT COLLATE utf8_unicode_ci NOT NULL,\n" + " PRIMARY KEY (`RECORDID`),\n" + " UNIQUE KEY `NTFNDATA_TEMPID_LOCID_OWNID_UQ` (`TEMPLATEID`,`LOCALEID`,`OWNERSITEID`)\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" ; parser.parse(ddl, tables); assertThat(((MySqlAntlrDdlParser) parser).getParsingExceptionsFromWalker().size()).isEqualTo(0); assertThat(tables.size()).isEqualTo(1); } Run the testcase.

    Description

      Query:

      CREATE TABLE `NTFCTN_TEMPLATE_DATA` (\n" +
                      " `RECORDID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `DATEADDED` DATETIME NOT NULL,\n" +
                      " `DATEMODIFIED` DATETIME NOT NULL,\n" +
                      " `TEMPLATEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `LOCALEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `OWNERSITEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n" +
                      " `ENABLE` CHARACTER(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `TASKENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `ROLEROUTINGENABLE` CHAR(1) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `NAME` VARCHAR(1000) COLLATE utf8_unicode_ci NOT NULL,\n" +
                      " `DATA` LONGTEXT COLLATE utf8_unicode_ci NOT NULL,\n" +
                      "  PRIMARY KEY (`RECORDID`),\n" +
                      "  UNIQUE KEY `NTFNDATA_TEMPID_LOCID_OWNID_UQ` (`TEMPLATEID`,`LOCALEID`,`OWNERSITEID`)\n" +
                  ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
      

      is giving parsing exception :

      [ERROR] Tests run: 125, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 31.706 s <<< FAILURE! - in io.debezium.connector.mysql.MySqlAntlrDdlParserTest
      [ERROR] shouldExceptChracterinCreateTable(io.debezium.connector.mysql.MySqlAntlrDdlParserTest)  Time elapsed: 0.071 s  <<< ERROR!
      io.debezium.text.ParsingException: no viable alternative at input 'CREATE TABLE `NTFCTN_TEMPLATE_DATA` (\n `RECORDID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n `DATEADDED` DATETIME NOT NULL,\n `DATEMODIFIED` DATETIME NOT NULL,\n `TEM\
      PLATEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n `LOCALEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n `OWNERSITEID` VARCHAR(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,\n `ENABLE` CHARACTER'
              at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:40)
              at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
              at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
              at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
          at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1094)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:828)
              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:68)
              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:41)
          at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:80)
              at io.debezium.connector.mysql.MySqlAntlrDdlParserTest.shouldExceptChracterinCreateTable(MySqlAntlrDdlParserTest.java:80)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
              at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
              at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
              at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
              at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
              at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
              at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
              at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
              at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
              at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
              at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
              at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
              at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
              at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
              at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
              at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
              at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
      Caused by: org.antlr.v4.runtime.NoViableAltException
              at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
              at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
              at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:902)
              ... 31 more
      

      If CHARACTER(1) is replaced with CHAR(1), then parser is happy.

      But the above query runs fine and creates a table in MySql.

      Above query is failing with version 1.0, 1.1. I did not test with other versions.

      Attachments

        Activity

          People

            jpechane Jiri Pechanec
            ritesh277coe Ritesh Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: