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

A temp table can not be re-declared after drop

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 16.0
    • 14.0
    • Query Engine
    • None
    • Hide

      1. In PostgreSQL create the test_a and table_d tables 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);
      
      CREATE TABLE public.test_d
      (
        d integer
      );
      INSERT INTO public.test_d(d) VALUES (3);
      INSERT INTO public.test_d(d) VALUES (1);
      INSERT INTO public.test_d(d) VALUES (3);
      

      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 SQL script:

      begin
      	select * into #temp from test_tables_pg.test_d limit 1;
      	drop table #temp;
      	select * into #temp from test_tables_pg.test_a limit 1;
      end ;;
      

      Teiid will generate the following error:

      2020-12-17 11:11:50,158 WARN  [org.teiid.PROCESSOR] (Worker5_QueryProcessorQueue89) lQ9m+sjafCwu TEIID30020 Processing exception for request lQ9m+sjafCwu.36 'TEIID30492 Wrong number of elements being SELECTed INTO the target table. Expected 1 elements, but was 2.'. Originally QueryValidatorException Request.java:343. Enable more detailed logging to see the entire stacktrace.
      

      because of not dropped #temp temporary table before inserting test_a table's data.

      Show
      1. In PostgreSQL create the test_a and table_d tables 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); CREATE TABLE public .test_d ( d integer ); INSERT INTO public .test_d(d) VALUES (3); INSERT INTO public .test_d(d) VALUES (1); INSERT INTO public .test_d(d) VALUES (3); 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 SQL script: begin select * into # temp from test_tables_pg.test_d limit 1; drop table # temp ; select * into # temp from test_tables_pg.test_a limit 1; end ;; Teiid will generate the following error: 2020-12-17 11:11:50,158 WARN [org.teiid.PROCESSOR] (Worker5_QueryProcessorQueue89) lQ9m+sjafCwu TEIID30020 Processing exception for request lQ9m+sjafCwu.36 'TEIID30492 Wrong number of elements being SELECTed INTO the target table. Expected 1 elements, but was 2.' . Originally QueryValidatorException Request.java:343. Enable more detailed logging to see the entire stacktrace. because of not dropped #temp temporary table before inserting test_a table's data.
    • Undefined

    Description

      If a temporary table is created implicitly then this table can not be dropped in the same scope.

      begin
      	select * into #temp from test_tables_pg.test_d limit 1;
      	drop table #temp;
      	select * into #temp from test_tables_pg.test_a limit 1;
      end ;;
      

      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: