Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-2015

NullPointerException in INSERT ... SELECT with self-joined table and IDENTITY column

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 10.2.1.6
    • None
    • SQL
    • None
    • Java 1.5.0_06-b05 WinXP

    Description

      The following statements generate a NullPointerException:

      CREATE TABLE t1 (
      f1 INTEGER);

      CREATE TABLE t2 (
      f2 INTEGER GENERATED ALWAYS AS IDENTITY,
      f3 INTEGER);

      INSERT INTO t2 (f3)
      SELECT a.f1
      FROM t1 a
      INNER JOIN t1 b ON a.f1 = b.f1;

      Stack trace:
      ----------------------------------------------------------------
      2006-10-28 21:29:17.937 GMT:
      Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.1.6 - (452058): instance c013800d-010e-90d3-9ea6-00000012fd20
      on database directory C:\temp_sys\temp_Derby_TestErr_db

      Database Class Loader started - derby.database.classpath=''
      2006-10-28 21:29:25.437 GMT Thread[main,5,main] (XID = 125), (SESSIONID = 0), (DATABASE = c:\temp_sys\temp_Derby_TestErr_db), (DRDAID = null), Cleanup action starting
      2006-10-28 21:29:25.437 GMT Thread[main,5,main] (XID = 125), (SESSIONID = 0), (DATABASE = c:\temp_sys\temp_Derby_TestErr_db), (DRDAID = null), Failed Statement is: INSERT INTO t2 (f3)
      SELECT a.f1
      FROM t1 a
      INNER JOIN t1 b ON a.f1 = b.f1
      java.lang.NullPointerException
      at org.apache.derby.impl.sql.compile.ResultColumnList.remapColumnReferencesToExpressions(Unknown Source)
      at org.apache.derby.impl.sql.compile.JoinNode.flatten(Unknown Source)
      at org.apache.derby.impl.sql.compile.FromList.flattenFromTables(Unknown Source)
      at org.apache.derby.impl.sql.compile.SelectNode.preprocess(Unknown Source)
      at org.apache.derby.impl.sql.compile.SingleChildResultSetNode.preprocess(Unknown Source)
      at org.apache.derby.impl.sql.compile.DMLStatementNode.optimize(Unknown Source)
      at org.apache.derby.impl.sql.compile.DMLModStatementNode.optimize(Unknown Source)
      at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
      at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
      at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
      at org.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown Source)
      at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
      at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
      at org.apache.derby.impl.tools.ij.Main14.main(Unknown Source)
      at org.apache.derby.tools.ij.main(Unknown Source)
      Cleanup action completed
      ----------------------------------------------------------------

      As with DERBY-1574, any subsequent SQL statements produce an internal error in the RawStore module.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chdh@inventec.ch Christian d'Heureuse
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: