db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DERBY-6013) Assert failure with ORDER BY in UNION used in sub-query
Date Thu, 13 Dec 2012 17:02:13 GMT
Knut Anders Hatlen created DERBY-6013:
-----------------------------------------

             Summary: Assert failure with ORDER BY in UNION used in sub-query
                 Key: DERBY-6013
                 URL: https://issues.apache.org/jira/browse/DERBY-6013
             Project: Derby
          Issue Type: Bug
          Components: SQL
    Affects Versions: 10.9.1.0
            Reporter: Knut Anders Hatlen


I see an assert failure when executing this sequence of statements using a debug version of
10.9.1.0 or trunk:

ij version 10.9
ij> connect 'jdbc:derby:memory:db;create=true';
ij> create table t(x int);
0 rows inserted/updated/deleted
ij> create table u(x int);
0 rows inserted/updated/deleted
ij> insert into t values 1,2,3,4,5;
5 rows inserted/updated/deleted
ij> insert into u values 4,5,6,7;
4 rows inserted/updated/deleted
ij> select * from sysibm.sysdummy1 where exists ((select * from t) union (select * from
u where x = 4) order by x);
ERROR XJ001: Java exception: 'ASSERT FAILED getMatchingColumn() not expected to be called
for tableConstructor: false
all: false
nestedInParens: false
correlation Name: null
null
tableNumber 3
level 1
resultSetNumber: 0
referencedTableMap: null
statementResultSet: false
: org.apache.derby.shared.common.sanity.AssertFailure'.

Using a non-debug build makes it fail more gracefully:

ij> select * from sysibm.sysdummy1 where exists ((select * from t) union (select * from
u where x = 4) order by x);
ERROR 42X04: Column 'X' is either not in any table in the FROM list or appears within a join
specification and is outside the scope of the join specification or appears in a HAVING clause
and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'X' is
not a column in the target table.

However, I think the error message is misleading, as X is a valid column in the query. Seen
for example by executing the nested query as a top-level query:

ij> (select * from t) union all (select * from u where x = 4) order by x;
X          
-----------
1          
2          
3          
4          
4          
5          

6 rows selected

However, possibly related, if I simply add parentheses around the working query, it again
fails with a complaint about the column X:

ij> ((select * from t) union all (select * from u where x = 4) order by x);
ERROR 42X78: Column 'X' is not in the result of the query expression.

--
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

Mime
View raw message