[
https://issues.apache.org/jira/browse/DERBY-3997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659630#action_12659630
]
Knut Anders Hatlen commented on DERBY-3997:
-------------------------------------------
I think I've found the cause of the problem. This code in
SelectNode.preprocess() will be executed when all the columns in the ORDER BY
clause are known to have constant values because of the WHERE clause:
/*
** It's possible for the order by list to
shrink to nothing
** as a result of removing constant columns.
If this happens,
** get rid of the list entirely.
*/
if (orderByList.size() == 0)
{
orderByList = null;
}
Later, in SelectNode.genProjectRestrict() the extra ORDER BY columns are
supposed to be removed from the result, but this is only done if orderByList !=
null, as it assumes that (orderByList == null) means that there are no columns
to remove. Calling resultColumns.removeOrderByColumns() when we set orderByList
to null appears to fix the problem, but I haven't run the regression tests yet.
> ORDER BY causes column to be returned
> -------------------------------------
>
> Key: DERBY-3997
> URL: https://issues.apache.org/jira/browse/DERBY-3997
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.4.1.3
> Environment: Mac OS 10.4, JDK 1,6
> Reporter: geoff hendrey
>
> The ORDER BY is causing the ordered column to be retrieved even though it is
> not part of the SELECT clause. Here is a script to create a table, insert a
> row, and perform the select:
> CREATE TABLE "REVIEWS"."GEOFF__REVIEWS__REVIEW"
> (
> PK INTEGER PRIMARY KEY not null,
> numstars BIGINT,
> body VARCHAR(32672),
> title VARCHAR(32672),
> authoremail VARCHAR(32672)
> );
> INSERT INTO "REVIEWS"."GEOFF__REVIEWS__REVIEW"
> (PK,numstars,body,title,authoremail) VALUES (0 /*not
> nullable*/,0,'s','s','s');
> SELECT "review"."numstars"
> FROM
> "GEOFF__REVIEWS__REVIEW" AS "review"
> WHERE
> "review"."PK" = 1
> ORDER BY
> "review".PK
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.