Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3351

In JDBC adapter, when generating SQL for MYSQL, MySQLSyntaxErrorException throws when there is non-ascii literal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.19.0
    • None
    • core
    • Happened on both Windows and MacOS.

    Description

      Exception was thrown when connecting with mySQL to query Chinese. The following SQL was executed:

      select * from \"test\".\"score_new\" where \"name\"= \'催\' limit 1

      ,if change "getDefaultCharset" in "RelDataTypeFactoryImpl" to

      return Charset.forName("UTF8");

      there will be also exception thrown as the following:

      java.sql.SQLException: Error while executing SQL "select * from "test"."score_new" where "name"= '催' limit 1": While executing SQL [SELECT *java.sql.SQLException: Error while executing SQL "select * from "test"."score_new" where "name"= '催' limit 1": While executing SQL [SELECT *FROM `score_new`WHERE `name` = u&'\50ac'LIMIT 1] on JDBC sub-schema at org.apache.calcite.avatica.Helper.createException(Helper.java:56) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) at QueryMysql.main(QueryMysql.java:42)Caused by: java.lang.RuntimeException: While executing SQL [SELECT *FROM `score_new`WHERE `name` = u&'\50ac'

      Attachments

        1. toSql Result.png
          106 kB
          JIasen Sheng
        2. e.condition.png
          123 kB
          JIasen Sheng

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jacky-cui cui
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Time Spent - 0.5h Remaining Estimate - 23.5h
                  23.5h
                  Logged:
                  Time Spent - 0.5h Remaining Estimate - 23.5h
                  0.5h