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

UNION query does not fail or fails with incorrect error message

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Blocker
    • None
    • 9.3.1
    • Query Engine
    • None
    • Hide

      1. In postgresql create the test_a table by the following script:

      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_pg" pool-name="test_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>postgres</user-name>
                              <password>xxxxxx</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_pg configured in previous step as datasource:

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

      4. Configure in the test-vdb.xml the following virtual procedure (which always fails):

      <model visible = "true" type = "VIRTUAL" name = "procs">
              <metadata type = "DDL"><![CDATA[
                CREATE virtual procedure pr() RETURNS (a integer) AS
                BEGIN
      	     SELECT 1/0;
                END        
              ]]>
              </metadata>
          </model>
      

      5. Run the following queries:

      select a from test_pg.test_a 
      union all
      select 1
      union all 
      select * from (call procs.pr()) x
      

      or

      select a from test_pg.test_a 
      union all
      select 1
      union all 
      select * from (call procs.pr()) x
      union all
      select a from test_pg.test_a
      
      Show
      1. In postgresql create the test_a table by the following script: 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_pg" pool-name= "test_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> postgres </user-name> <password> xxxxxx </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_pg configured in previous step as datasource: <model name= "test_pg" > <property name= "importer.useFullSchemaName" value= "false" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.importKeys" value= "false" /> <source name= "test_pg" translator-name= "myPg" connection-jndi-name= "java:/test_pg" /> </model> 4. Configure in the test-vdb.xml the following virtual procedure (which always fails): <model visible = "true" type = "VIRTUAL" name = "procs" > <metadata type = "DDL" > <![CDATA[ CREATE virtual procedure pr() RETURNS (a integer) AS BEGIN SELECT 1/0; END ]]> </metadata> </model> 5. Run the following queries: select a from test_pg.test_a union all select 1 union all select * from ( call procs.pr()) x or select a from test_pg.test_a union all select 1 union all select * from ( call procs.pr()) x union all select a from test_pg.test_a

    Description

      Running the following queries:

      select a from test_pg.test_a 
      union all
      select 1
      union all 
      select * from (call procs.pr()) x
      

      or

      select a from test_pg.test_a 
      union all
      select 1
      union all 
      select * from (call procs.pr()) x
      union all
      select a from test_pg.test_a
      

      UNION queries do not fail or fail with an incorrect error message returning no results.
      That is the first run will return the following stacktrace in logs:

      2017-09-12 15:06:26,585 WARN  [org.teiid.PROCESSOR] (Worker2_QueryProcessorQueue7) XH74byN2GJ4K TEIID30020 Processing exception for request XH74byN2GJ4K.0 'TEIID30167 org.teiid.jdbc.
      TeiidSQLException: TEIID30328 Unable to evaluate (1 / 0): TEIID30384 Error while evaluating function /'. Originally ProcedureErrorInstructionException '/ by zero' FunctionMethods.jav
      a:296. Enable more detailed logging to see the entire stacktrace.
      

      returning no results, the second run of the same query will return:

      2017-09-12 15:07:39,427 WARN  [org.teiid.PROCESSOR] (Worker2_QueryProcessorQueue10) XH74byN2GJ4K TEIID30020 Processing exception for request XH74byN2GJ4K.1 'TEIID30167 org.teiid.jdbc
      .TeiidSQLException: TEIID30328 Unable to evaluate (1 / 0): TEIID30384 Error while evaluating function /'. Originally ProcedureErrorInstructionException '/ by zero' FunctionMethods.ja
      va:296. Enable more detailed logging to see the entire stacktrace.
      2017-09-12 15:07:39,434 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,450 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,454 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,465 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,470 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,474 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,483 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,487 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,500 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,506 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,516 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,520 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,534 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,538 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      2017-09-12 15:07:39,549 WARN  [org.teiid.PROCESSOR] (NIO1) XH74byN2GJ4K TEIID40011 Processing exception 'TEIID30495 The request XH74byN2GJ4K.1 has been closed.' for session XH74byN2G
      J4K.  Exception type org.teiid.core.TeiidProcessingException thrown from org.teiid.dqp.internal.process.DQPCore.getRequestWorkItem(DQPCore.java:475). Enable more detailed logging to
      see the entire stacktrace.
      

      again without any query results.
      So these queries should return error messages like usual call of the virtual procedure pr does:

      call procs.pr()
      

      instead of just closing requests.

      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: