[ http://issues.apache.org/jira/browse/DERBY-681?page=all ]
Manish Khettry updated DERBY-681:
---------------------------------
Attachment: 681.patch.txt
This patch removes the "wrap group by's in a subselect" rewrite in the parser.
It preserves the having clause through bind and optimize phases and during the
final rewrite for aggregates in the GroupByNode, transforms the having clause
to a valid restriction. I am also attaching a text file which should clarify
the changes.
This patch also fixes related bugs DERBY-1624, the regresssion introduced by
DERBY-280 and also completes the functionality for DERBY-883.
If this patch is approved and comitted I will file another bug to remove
references to the flags generatedForGroupBy and geneatedForHaving which is dead
code post this patch. I did not remove these references because it would make
the patch even bigger and more complicated.
> 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
> Issue Type: Improvement
> Components: SQL
> Reporter: Rick Hillegas
> Assigned To: Manish Khettry
> Attachments: 681.patch.txt, notes.txt
>
>
> 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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira