Issue Details (XML | Word | Printable)

Key: DERBY-2015
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Christian d'Heureuse
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Derby

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

Created: 28/Oct/06 09:36 PM   Updated: 13/Dec/07 09:05 AM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Java 1.5.0_06-b05 WinXP
Issue Links:
Duplicate
 

Resolution Date: 23/Nov/06 05:36 PM


 Description  « Hide
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.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Bryan Pendleton added a comment - 14/Nov/06 12:50 AM
I think this is a duplicate of DERBY-1089. Christian, can you try the patch attached to DERBY-1089 and see if it resolves the problem for you?

Bryan Pendleton made changes - 14/Nov/06 05:21 AM
Field Original Value New Value
Link This issue relates to DERBY-1089 [ DERBY-1089 ]
Repository Revision Date User Message
ASF #478622 Thu Nov 23 17:27:39 UTC 2006 bpendleton DERBY-1089: NPE inserting a join into a table with a generated column
DERBY-2015: NPE in INSERT .. SELECT with IDENTITY column

When an INSERT ... SELECT statement inserts a GENERATED ALWAYS identity
column, the identity column's column reference is NULL, since that
column does not have a corresponding column in the SELECT list. This
NULL expression needs to be skipped over when remapping column references
from the SELECT column list to the INSERT column list.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/joins.out
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java

Bryan Pendleton made changes - 23/Nov/06 05:35 PM
Link This issue duplicates DERBY-1089 [ DERBY-1089 ]
Bryan Pendleton made changes - 23/Nov/06 05:35 PM
Link This issue relates to DERBY-1089 [ DERBY-1089 ]
Bryan Pendleton added a comment - 23/Nov/06 05:36 PM
Marking as a duplicate of DERBY-1089

Bryan Pendleton made changes - 23/Nov/06 05:36 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Duplicate [ 3 ]
Repository Revision Date User Message
ASF #478658 Thu Nov 23 20:42:54 UTC 2006 bpendleton DERBY-1089: NPE inserting a join into a table with a generated column
DERBY-2015: NPE in INSERT .. SELECT with IDENTITY column

Merged the patch from trunk with merge -r 478621:478622 ../trunk/
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/joins.out
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java

Andrew McIntyre added a comment - 13/Dec/07 09:05 AM
This issue has been resolved for over a year with no further movement. Closing.

Andrew McIntyre made changes - 13/Dec/07 09:05 AM
Status Resolved [ 5 ] Closed [ 6 ]