db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: Nested SELECT in selected columns list causes NullPointerException if it references ROW_NUMBER() OVER() function
Date Wed, 17 Oct 2012 13:41:19 GMT
On 10/17/12 6:30 AM, drv wrote:
> ==================================================
> These queries fail:
> ==================================================
>
> create table blah ( a int )
> insert into blah values (1), (2), (3), (4), (5), (6), (7)
>
> SELECT rn, (SELECT rn FROM (SELECT row_number() over() rn FROM blah ) as T2
> where T2.rn = T1.rn+1) rn2
> FROM (SELECT row_number() over() rn from blah) as T1
>
> =>  The exception 'java.lang.NullPointerException' was thrown while
> evaluating an expression.
>
>
> OR using a values() expression instead of table 'blah':
>
> SELECT rn, (SELECT rn FROM (SELECT row_number() over() rn FROM (values(1),
> (2), (3)) V ) as T2 where T2.rn = T1.rn+1) rn2
> FROM (SELECT row_number() over() rn from (values(1), (2), (3)) V) as T1
>
> =>  DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ001, SQLERRMC:
> java.lang.NullPointerExceptionXJ001.U
>
>
> ==================================================
> Exception logged in derby.log:
> ==================================================
>
> Wed Oct 17 14:21:30 BST 2012 Thread[DRDAConnThread_13,5,derby.daemons] (XID
> = 9070), (SESSIONID = 11), (DATABASE = gaiandb), (DRDAID =
> ????????.????-1011338240841373641{10}), Cleanup action starting
> Wed Oct 17 14:21:30 BST 2012 Thread[DRDAConnThread_13,5,derby.daemons] (XID
> = 9070), (SESSIONID = 11), (DATABASE = gaiandb), (DRDAID =
> ????????.????-1011338240841373641{10}), Failed Statement is: SELECT rn,
> (SELECT rn FROM (SELECT row_number() over() rn FROM (values(1), (2), (3)) V
> ) as T2 where T2.rn = T1.rn+1) rn2
> FROM (SELECT row_number() over() rn from (values(1), (2), (3)) V) as T1
> java.lang.NullPointerException
> 	at org.apache.derby.impl.sql.compile.ResultColumnList.updateArrays(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.compile.ResultColumnList.mapSourceColumns(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown
> Source)
> 	at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown
> Source)
> 	at org.apache.derby.impl.sql.compile.WindowResultSetNode.generate(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(Unknown
> Source)
> 	at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode.generate(Unknown
> Source)
> 	at org.apache.derby.impl.sql.compile.CursorNode.generate(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.StatementNode.generate(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.EmbedPreparedStatement.<init>(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown
> Source)
> 	at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> 	at org.apache.derby.impl.drda.DRDAStatement.prepare(Unknown Source)
> 	at org.apache.derby.impl.drda.DRDAStatement.explicitPrepare(Unknown Source)
> 	at org.apache.derby.impl.drda.DRDAConnThread.parsePRPSQLSTT(Unknown Source)
> 	at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown
> Source)
> 	at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
> Cleanup action completed
Thanks for the compact repro. I have verified this behavior logged the 
bug as https://issues.apache.org/jira/browse/DERBY-5954.

Thanks,
-Rick

Mime
View raw message