db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Klebanoff <klebanoff-de...@sbcglobal.net>
Subject [PATCH] Derby-127
Date Thu, 05 May 2005 16:38:12 GMT
I have attached a patch that fixes Jira bug Derby-127 
(http://issues.apache.org/jira/browse/DERBY-127). The problem is with 
select statements that use a correlation name in the select list, a 
group by clause, and an order by clause that refers to a column by its 
database name instead of its correlation name. e.g.
  select c1 as x from t where ... group by x order by c1
Derby throws an exception with SQLState 42x04 complaining that it cannot 
resolve "c1".

The underlying problem is that the Derby parser transforms the select 
into a query tree for the following statement:
  select * from (select c1 as x from t where ...) order by c1
The code in class OrderByColumn did not take this into account. I 
changed methods pullUpOrderByColumn and bindOrderByColumn to handle this 
case specially. pullUpOrderByColumn adds the sort key to the 
ResultColumnList if it cannot find it there. It is called before binding 
and before select list wildcards ("*") are expanded. I changed it to 
pull the sort key into the ResultColumnList of the subselect generated 
to handle GROUP BY. I also changed it to remember where it was added. 
This simplifies the bindOrderByColumn, which is called after 

I also fixed the handling of table names in class OrderByColumn. It 
treated them as strings, which does not work when the schema or table 
name is a quoted string containing a period. I changed OrderByColumn to 
use class TableName to represent a table name. The 
ResultColumnList.getOrderByColumn methods where changed accordingly

Jack Klebanoff.

View raw message