If anyone feels strongly about reclassifying this as an enhancement, they are welcome to do so. I filed it as a bug fix because it seemed to me to address the root cause of a nest of bugs.

Cheers,
-Rick

Satheesh Bandaram (JIRA) wrote:

[ http://issues.apache.org/jira/browse/DERBY-681?page=comments#action_12356724 ]
Satheesh Bandaram commented on DERBY-681:
-----------------------------------------

Should this be marked an Enhancement request? While I agree the current scheme 
of rewriting the query can be improved, it does achieve the functionality. Bugs 
in the current implementation have been logged separately. (like DERBY-280) 
Changing the mechanism should be marked an Enhancement, I think.

Eliminate the parser's rewriting of the abstract syntax tree for queries with 
GROUP BY and/or HAVING clauses
------------------------------------------------------------------------------------------------------------

        Key: DERBY-681
        URL: http://issues.apache.org/jira/browse/DERBY-681
    Project: Derby
       Type: Improvement
   Reporter: Rick Hillegas

If a query contains a GROUP BY or HAVING clause, the parser rewrites the 
abstract syntax tree, putting aggregates into a subselect and treating the 
HAVING clause as the WHERE clause of a fabricated outer select from the 
subquery. This allows the compiler to re-use some machinery since the HAVING 
clause operates on the grouped result the way that the WHERE clause operates on 
the from list. Unfortunately, this rewriting creates an explosion of special 
cases in the compiler after parsing is done. The rewriting is not 
systematically handled later on in the compiler. This gives rise to defects 
like bug 280. We need to eliminate this special rewriting and handle the HAVING 
clause in a straightforward way. This is not a small bugfix but is a medium 
sized project.


Reply via email to