[
https://issues.apache.org/jira/browse/DERBY-2459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499315
]
Bryan Pendleton commented on DERBY-2459:
----------------------------------------
Pursuing option #2 has advanced me to a point where I now get
through all of bind and optimize processing, and crash in generate
processing. I'm not sure if this is still a problem with the basic data
structures, or if it's just the case that OrderByList.generate has never
been called with a CASE expression before. I suspect that I've still
got a problem with bind processing, because the ColumnReference
information in the OrderByColumn seems to be wrong. I think the
ColRef in the ORDER BY's CASE statement didn't get bound to the
underlying result column properly. Here's a snip of the
new stack trace I'm looking at:
org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED
sourceResultSetNumber expected to be >= 0 for T2.VALUE
at
org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:162)
at
org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:147)
at
org.apache.derby.impl.sql.compile.ColumnReference.generateExpression(ColumnReference.java:951)
at
org.apache.derby.impl.sql.compile.UnaryOperatorNode.generateExpression(UnaryOperatorNode.java:682)
at
org.apache.derby.impl.sql.compile.NotNode.generateExpression(NotNode.java:116)
at
org.apache.derby.impl.sql.compile.ConditionalNode.generateExpression(ConditionalNode.java:678)
at
org.apache.derby.impl.sql.compile.ResultColumn.generateExpression(ResultColumn.java:891)
at
org.apache.derby.impl.sql.compile.ResultColumnList.generateCore(ResultColumnList.java:1177)
at
org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(ProjectRestrictNode.java:1515)
at
org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(ProjectRestrictNode.java:1302)
at org.apache.derby.impl.sql.compile.UnionNode.generate(UnionNode.java:589)
at
org.apache.derby.impl.sql.compile.OrderByList.generate(OrderByList.java:402)
at
org.apache.derby.impl.sql.compile.OrderByNode.generate(OrderByNode.java:155)
> Ordering on a CASE-expression casues a NullPointerException when using a UNION
> ------------------------------------------------------------------------------
>
> Key: DERBY-2459
> URL: https://issues.apache.org/jira/browse/DERBY-2459
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.1.3.1, 10.1.3.2, 10.2.1.6, 10.2.2.0, 10.2.2.1,
> 10.3.0.0
> Environment: Java 1.5.0_06-b05 on Linux Ubuntu 5.10. Derby version
> 10.2.2
> Reporter: Lars Gråmark
> Assigned To: Bryan Pendleton
>
> When an order by clause involves a CASE-expression as seen below, a
> NullPointerException is thrown. The error only occurs when two select
> statements are combined in a union (or union all).
> select t1.id, CASE WHEN t2.value IS NOT NULL THEN t2.value ELSE t1.value END
> from A1 t1
> left outer join B1 t2 ON t2.id = t1.ref
> union all
> select t1.id, CASE WHEN t2.value IS NOT NULL THEN t2.value ELSE t1.value END
> from A2 t1
> left outer join B2 t2 ON t2.id = t1.ref
> order by CASE WHEN t2.value IS NOT NULL THEN t2.value ELSE t1.value END
> --Use the following statement to reproduce the problem:
> create table A1
> (
> id char(1)
> ,value int
> ,ref char(1)
> );
> create table A2
> (
> id char(1)
> ,value int
> ,ref char(1)
> );
> create table B1
> (
> id char(1)
> ,value int
> );
> create table B2
> (
> id char(1)
> ,value int
> );
> insert into A1 (id, value, ref) values ('a', 12, 'e');
> insert into A1 (id, value, ref) values ('b', 1, null);
> insert into A2 (id, value, ref) values ('c', 3, 'g');
> insert into A2 (id, value, ref) values ('d', 8, null);
> insert into B1 (id, value) values ('e', 4);
> insert into B1 (id, value) values ('f', 2);
> insert into B2 (id, value) values ('g', 5);
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.