NullPointerException at ResultSet.close() time for simple query using UNION and 
INTERSECT
-----------------------------------------------------------------------------------------

         Key: DERBY-939
         URL: http://issues.apache.org/jira/browse/DERBY-939
     Project: Derby
        Type: Bug
    Versions: 10.2.0.0    
 Environment: Derby 10.2 trunk -- embedded and server modes
    Reporter: A B


If I attempt to execute the following simple query using UNION and INTERSECT, 
Derby will return the correct results and then, _after_ returning the results, 
will throw a NullPointerException.  This error does *NOT* occur for Derby 10.1, 
hence I'm marking it as "Major" since it seems like a regression.

348600

To reproduce:

create table t1 (i int);
create table t2 (j int);
create table t3 (a int);

ij> select i from t1 union (select j from t2 intersect select a from t3);
1
-----------

0 rows selected
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

If I add data, the query will return the correct results,  but then throw the 
NPE.

insert into t1 values 1, 2, 3, 4, 5;
insert into t2 values 2, 4, 6, 8, 10;
insert into t3 values 2, 3, 4;

ij> select i from t1 union (select j from t2 intersect select a from t3);
1
-----------
1
2
3
4
5

5 rows selected
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.

The embedded and client stack traces are shown below. Both suggest that the 
problem occurs during the close of the result set.

-- Embedded --

java.lang.NullPointerException
        at 
org.apache.derby.impl.sql.execute.rts.RealUnionResultSetStatistics.getStatementExecutionPlanText(RealUnionResultSetStatistics.java:107)
        at 
org.apache.derby.impl.sql.execute.rts.RealSortStatistics.getStatementExecutionPlanText(RealSortStatistics.java:124)
        at 
org.apache.derby.impl.sql.execute.rts.RunTimeStatisticsImpl.getStatementExecutionPlanText(RunTimeStatisticsImpl.java:293)
        at 
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.finishAndRTS(BasicNoPutResultSetImpl.java:633)
        at 
org.apache.derby.impl.sql.execute.SortResultSet.finish(SortResultSet.java:479)
        at 
org.apache.derby.impl.jdbc.EmbedResultSet.close(EmbedResultSet.java:533)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272)
        at 
org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260)
        at 
org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381)
        at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
        at org.apache.derby.tools.ij.main(ij.java:60)

-- Client --

We get an "actual code point does not match expected code point", but further 
down the stack is the NPE:

ERROR XJ001: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: 
java.lang.NullPointerException
¶¶XJ001.U
java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC: 
java.lang.NullPointerException¶¶XJ001.U
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:280)
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:295)
        at org.apache.derby.client.am.ResultSet.close(ResultSet.java:412)
        at 
org.apache.derby.tools.JDBCDisplayUtil.indent_DisplayResults(JDBCDisplayUtil.java:272)
        at 
org.apache.derby.tools.JDBCDisplayUtil.DisplayResults(JDBCDisplayUtil.java:260)
        at 
org.apache.derby.impl.tools.ij.utilMain.displayResult(utilMain.java:381)
        at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:434)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
        at org.apache.derby.tools.ij.main(ij.java:60)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to