db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dag H. Wanvik (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6009) Need stricter checking of ORDER BY clause in VALUES expressions
Date Sun, 30 Dec 2012 02:34:12 GMT

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

Dag H. Wanvik commented on DERBY-6009:

Thanks for looking at this one, Knut. The current patch does throw 1 and 2). I'll file another
bug for 3) since it's a different issue. Btw, it happens for SELECT, too. Once, that's fixed,
it should throw error on 3) due to the new patch here.

[The NPE happens when pulling up the order by expression seemingly due to a compiler phase

Caused by: java.lang.NullPointerException
	at org.apache.derby.impl.sql.compile.CastNode.getConstantValueAsObject(CastNode.java:851)
	at org.apache.derby.impl.sql.compile.OrderByColumn.isReferedColByNum(OrderByColumn.java:466)
	at org.apache.derby.impl.sql.compile.OrderByColumn.pullUpOrderByColumn(OrderByColumn.java:403)
	at org.apache.derby.impl.sql.compile.OrderByList.pullUpOrderByColumns(OrderByList.java:195)
	at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:254)

The variable sourceCTI is (still) null; being set by CastNode# bindCastNodeOnly, which presumably
hasn't yet been run.

Uploading version b of this patch; there was a trailing a blanks issue in the canon for the
orderby.sql script, otherwise the regressions passed without error.

> Need stricter checking of ORDER BY clause in VALUES expressions
> ---------------------------------------------------------------
>                 Key: DERBY-6009
>                 URL: https://issues.apache.org/jira/browse/DERBY-6009
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:
>            Reporter: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: derby-6009.diff, derby-6009.stat
> We only support column numbers in ORDER BY clauses in VALUES expression, as seen by this
error message:
> ij> values 1,2 order by 1+2;
> ERROR 42878: The ORDER BY clause of a SELECT UNION statement only supports unqualified
column references and column position numbers. Other expressions are not currently supported.
(errorCode = 30000)
> However, the checks let some unsupported expressions through and produce strange results.
For example:
> ij> values 1 order by 1+2;
> 1          |2          
> -----------------------
> 1          |3          
> 1 row selected
> It should probably have raised the same exception as the first query. And if not, the
result should only have had one column.
> And the next example should probably have raised a syntax error too, instead of a NullPointerException:
> ij> values 1 order by int(1);
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'. (errorCode = 0)

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message