Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-6047

Comments become source hints and cause NPE

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 15.0.1, 14.0.2, 16.0
    • 14.0
    • Query Engine
    • None
    • Hide

      1. In PostgreSQL create the test_a table using the following scripts:

      CREATE TABLE public.test_a
      (
        a integer,
        b integer
      );
      INSERT INTO public.test_a(a, b) VALUES (1, 1);
      INSERT INTO public.test_a(a, b) VALUES (1, 2);
      INSERT INTO public.test_a(a, b) VALUES (2, 1);
      INSERT INTO public.test_a(a, b) VALUES (2, 2);
      INSERT INTO public.test_a(a, b) VALUES (3, 2);
      INSERT INTO public.test_a(a, b) VALUES (3, 10);
      

      2. Add PostgreSQL database configuration in standalone-teiid.xml:

                      <datasource jndi-name="java:/test_tables_pg" pool-name="test_tables_pg" enabled="true" use-java-context="true">
                          <connection-url>jdbc:postgresql://localhost:5432/test?charSet=utf8</connection-url>
                          <driver-class>org.postgresql.Driver</driver-class>
                          <driver>org.postgresql</driver>
                          <pool>
                              <min-pool-size>2</min-pool-size>
                              <max-pool-size>70</max-pool-size>
                              <prefill>false</prefill>
                              <use-strict-min>false</use-strict-min>
                              <flush-strategy>FailingConnectionOnly</flush-strategy>
                          </pool>
                          <security>
                              <user-name>XXXXX</user-name>
                              <password>XXXXX</password>
                          </security>
                          <validation>
                              <check-valid-connection-sql>select 0</check-valid-connection-sql>
                          </validation>
                          <timeout>
                              <blocking-timeout-millis>120000</blocking-timeout-millis>
                              <idle-timeout-minutes>5</idle-timeout-minutes>
                          </timeout>
                      </datasource>
      

      3. Add in test-vdb.xml java:/test_tables_pg configured in the previous step as a data source:

          <model name="test_tables_pg">
              <property name="importer.useFullSchemaName" value="false"/>
              <property name="importer.tableTypes" value="TABLE,VIEW"/>
              <property name="importer.importKeys" value="false"/>
              <source name="test_tables_pg" translator-name="myPg" connection-jndi-name="java:/test_tables_pg"/>
          </model>
      

      4. Run the following query:

      select
      -- shoes 
      	a
      from test_tables_pg.test_a a ;;
      

      will result to the following SQL in query planner:

      OPTIMIZATION COMPLETE:                                                                                                                                                                PROCESSOR PLAN:                                                                                                                                                                       AccessNode(0) output=[a.a] SELECT /*+sh */ g_0.a FROM test_tables_pg.test_a AS g_0
      

      have a look at /+sh/ hint though I didn't use a hint explicitly. If you run the same query but without a comment:

      select
      	a
      from test_tables_pg.test_a a ;;
      

      you will see no hints:

      OPTIMIZATION COMPLETE:                                                                                                                                                                PROCESSOR PLAN:                                                                                                                                                                       AccessNode(0) output=[a.a] SELECT g_0.a FROM test_tables_pg.test_a AS g_0
      

      A note: I used SQuirrel to run the query but it removes all comments from there, so I had to change the query in RequestMessage object in RequestWorkItem class' constructor in debug mode, for that I used the following string value: "select\n\t-- shoes\n\ta\nfrom test_tables_pg.test_a a" otherwise it's impossible to reproduce the bug on Teiid.

      5. The same bug is for such a query:

      select
      /* channel.md5_key_short */
      	a
      from test_tables_pg.test_a a ;;
      

      A note: I used the following string value:
      "select\n/* channel.md5_key_short */\n\ta\nfrom test_tables_pg.test_a a" in RequestMessage object in RequestWorkItem class' constructor in debug mode.

      Show
      1. In PostgreSQL create the test_a table using the following scripts: CREATE TABLE public .test_a ( a integer , b integer ); INSERT INTO public .test_a( a , b) VALUES (1, 1); INSERT INTO public .test_a( a , b) VALUES (1, 2); INSERT INTO public .test_a( a , b) VALUES (2, 1); INSERT INTO public .test_a( a , b) VALUES (2, 2); INSERT INTO public .test_a( a , b) VALUES (3, 2); INSERT INTO public .test_a( a , b) VALUES (3, 10); 2. Add PostgreSQL database configuration in standalone-teiid.xml: <datasource jndi-name= "java:/test_tables_pg" pool-name= "test_tables_pg" enabled= "true" use-java-context= "true" > <connection-url> jdbc:postgresql://localhost:5432/test?charSet=utf8 </connection-url> <driver-class> org.postgresql.Driver </driver-class> <driver> org.postgresql </driver> <pool> <min-pool-size> 2 </min-pool-size> <max-pool-size> 70 </max-pool-size> <prefill> false </prefill> <use-strict-min> false </use-strict-min> <flush-strategy> FailingConnectionOnly </flush-strategy> </pool> <security> <user-name> XXXXX </user-name> <password> XXXXX </password> </security> <validation> <check-valid-connection-sql> select 0 </check-valid-connection-sql> </validation> <timeout> <blocking-timeout-millis> 120000 </blocking-timeout-millis> <idle-timeout-minutes> 5 </idle-timeout-minutes> </timeout> </datasource> 3. Add in test-vdb.xml java:/test_tables_pg configured in the previous step as a data source: <model name= "test_tables_pg" > <property name= "importer.useFullSchemaName" value= "false" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.importKeys" value= "false" /> <source name= "test_tables_pg" translator-name= "myPg" connection-jndi-name= "java:/test_tables_pg" /> </model> 4. Run the following query: select -- shoes a from test_tables_pg.test_a a ;; will result to the following SQL in query planner: OPTIMIZATION COMPLETE: PROCESSOR PLAN: AccessNode(0) output=[a.a] SELECT /*+sh */ g_0.a FROM test_tables_pg.test_a AS g_0 have a look at / +sh / hint though I didn't use a hint explicitly. If you run the same query but without a comment: select a from test_tables_pg.test_a a ;; you will see no hints: OPTIMIZATION COMPLETE: PROCESSOR PLAN: AccessNode(0) output=[a.a] SELECT g_0.a FROM test_tables_pg.test_a AS g_0 A note: I used SQuirrel to run the query but it removes all comments from there, so I had to change the query in RequestMessage object in RequestWorkItem class' constructor in debug mode, for that I used the following string value: "select\n\t-- shoes\n\ta\nfrom test_tables_pg.test_a a" otherwise it's impossible to reproduce the bug on Teiid. 5. The same bug is for such a query: select /* channel.md5_key_short */ a from test_tables_pg.test_a a ;; A note: I used the following string value: "select\n/* channel.md5_key_short */\n\ta\nfrom test_tables_pg.test_a a" in RequestMessage object in RequestWorkItem class' constructor in debug mode.
    • Undefined

    Description

      Comments can become hints, despite no hint syntax is used within the comments. This can result in NPE on the execution of the query.

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            dalex005 Dmitrii Pogorelov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: