Issue Details (XML | Word | Printable)

Key: DERBY-2218
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Yip Ng
Reporter: A B
Votes: 0
Watchers: 0
Operations

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

Null Pointer Exception when an untyped NULL subquery ("values null") appears outside of the FROM list in a SELECT query.

Created: 05/Jan/07 10:50 PM   Updated: 24/Jan/08 05:00 PM
Return to search
Component/s: SQL
Affects Version/s: 10.1.3.2, 10.2.2.1, 10.2.3.0, 10.3.1.4
Fix Version/s: 10.2.2.1, 10.2.3.0, 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works derby2218-10.2-diff01.txt 2007-02-21 11:25 PM Yip Ng 6 kB
Text File Licensed for inclusion in ASF works derby2218-10.2-stat01.txt 2007-02-21 11:25 PM Yip Ng 0.5 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-diff01.txt 2007-01-06 05:12 AM Yip Ng 2 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-diff02.txt 2007-01-10 08:09 PM Yip Ng 4 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-diff03.txt 2007-01-20 04:39 AM Yip Ng 3 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-stat01.txt 2007-01-06 05:12 AM Yip Ng 0.3 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-stat02.txt 2007-01-10 08:09 PM Yip Ng 0.3 kB
Text File Licensed for inclusion in ASF works derby2218-trunk-stat03.txt 2007-01-20 04:39 AM Yip Ng 0.3 kB

Resolution Date: 21/Feb/07 06:59 PM


 Description  « Hide
If a SELECT query contains a subquery which includes an untyped NULL value at any place other than in the FROM list, Derby will throw an NPE at bind time.

ij> create table t1 (i int);
0 rows inserted/updated/deleted

-- If the untyped NULL is in the FROM list, a reasonable error is thrown.

ij> select * from (values null) x;
ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.

ij> select * from (select * from t1, (values null) x )y;
ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.

-- But if it appears anywhere else, the result is an NPE:

-- IN-list
ij> select * from t1 where i in (1, 2, (values null));
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

-- where clause
select * from t1 where (values null);

-- order by clause
select * from t1 order by (values null);

-- result column
select (values null) from t1;

-- group by clause (only works in 10.2 and later)
select * from t1 group by (values null);

-- having clause
select * from t1 group by i having (values null);

Stack trace (from 10.2.2) is:

java.lang.NullPointerException
at org.apache.derby.impl.sql.compile.SubqueryNode.setDataTypeServices(SubqueryNode.java:2289)
at org.apache.derby.impl.sql.compile.SubqueryNode.bindExpression(SubqueryNode.java:529)
at org.apache.derby.impl.sql.compile.ValueNodeList.bindExpression(ValueNodeList.java:130)
at org.apache.derby.impl.sql.compile.BinaryListOperatorNode.bindExpression(BinaryListOperatorNode.java:161)
at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(SelectNode.java:540)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(DMLStatementNode.java:249)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:162)
at org.apache.derby.impl.sql.compile.CursorNode.bind(CursorNode.java:253)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:345)
at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:119)

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #498004 Fri Jan 19 23:26:37 UTC 2007 abrown DERBY-2218: Patch to catch untyped null in SubqueryNode at bind phase.

Contributed by Yip Ng (yipng168@gmail.com)
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql

Repository Revision Date User Message
ASF #498689 Mon Jan 22 16:45:57 UTC 2007 abrown DERBY-2218: Follow-up patch for additional tests plus removal of an
unneeded call to bindResultColumns in SubqueryNode.

Contributed by Yip Ng (yipng168@gmail.com)
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out

Repository Revision Date User Message
ASF #510562 Thu Feb 22 15:57:43 UTC 2007 abrown DERBY-2218: Manual merge of svn #498004 and svn #498689 to 10.2 trunk.

Contributed by: Yip Ng (yipng168@gmail.com)
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql