db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6688) NPE (or sane: ASSERT failure) with ROW_NUMBER in some subqueries
Date Wed, 06 Aug 2014 20:04:16 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14088153#comment-14088153
] 

ASF subversion and git services commented on DERBY-6688:
--------------------------------------------------------

Commit 1616332 from [~dagw] in branch 'code/trunk'
[ https://svn.apache.org/r1616332 ]

DERBY-6688 NPE (or sane: ASSERT failure) with ROW_NUMBER in some subqueries

In FromSubquery (used in the OK subquery) the phasing is different
than in SubqueryNode (used in the failing query): the order by list is
pushed down too late in the SubqueryNode (after the
SelectNode#preprocess), so that the fact that the order by carries an
implicit window definition isn't recorded, causing the "windows" field
to be null, leading to missing rewriting in the getProjectRestrict
phase, hence the error.

In FromSubquery, the order by list is pushed down into the child
select node just before calling its preprocess method, i.e. the order
by list is present what that happens.

The patch (derby-6688-b) moves the pushing down of the order by list
in SubqueryNode#preprocess to the resultSet (the SelectNode) to just
before the call to preprocess of the resultSet, so the rest of the
windows rewriting machinery kicks in.

> NPE (or sane: ASSERT failure) with ROW_NUMBER in some subqueries
> ----------------------------------------------------------------
>
>                 Key: DERBY-6688
>                 URL: https://issues.apache.org/jira/browse/DERBY-6688
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>         Attachments: derby-6688-b.diff, derby-6688-b.status, derby-6688.diff
>
>
> This subquery usage works:
> {code}
> select * from (select x from t order by row_number() over () fetch first 1 row only)
tt;
> {code}
> but this one leads to NPE in insane mode, or a Sanity ASSERT failure in sane mode:
> {code}
> select * from t where x =  (select x from t order by row_number() over () fetch first
row only);
> {code}
> leading to this error:
> {code}
> Exception in thread "main" java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>         at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
>         at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
Source)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
Source)
>         at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
>         at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
>         at derby6565.Derby6565.main(Derby6565.java:33)
> Caused by: ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown
Source)
>         ... 11 more
> Caused by: java.lang.NullPointerException
>         at org.apache.derby.impl.sql.compile.UnaryOperatorNode.getReceiverInterfaceName(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.UnaryOperatorNode.generateExpression(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumn.generateExpression(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.generateEvaluatedRow(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(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.OrderByList.generate(Unknown Source)
>         at org.apache.derby.impl.sql.compile.OrderByNode.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.RowCountNode.generate(Unknown Source)
>         at org.apache.derby.impl.sql.compile.SubqueryNode.generateExpression(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.BinaryOperatorNode.generateExpression(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumn.generateExpression(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.generateEvaluatedRow(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(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.UpdateNode.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)
>         ... 3 more
> {code}
> The immediate problem is that the field *#operand* is null.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message