mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
GROUP BY got confused if there were multiple equal() GROUP BY items.
This bug has been latent since 7.0 or maybe even further back, but it was only exposed when parse_clause.c stopped suppressing duplicate items (see its rev 1.96 of 18-Aug-02).
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.151 2003/03/10 03:53:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.152 2003/03/13 16:58:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1489,13 +1489,14 @@ make_groupsortplan(Query *parse,
|
||||
Plan *subplan)
|
||||
{
|
||||
List *sort_tlist = new_unsorted_tlist(subplan->targetlist);
|
||||
int grpno = 0;
|
||||
int keyno = 0;
|
||||
List *gl;
|
||||
|
||||
foreach(gl, groupClause)
|
||||
{
|
||||
GroupClause *grpcl = (GroupClause *) lfirst(gl);
|
||||
TargetEntry *te = nth(grpColIdx[keyno] - 1, sort_tlist);
|
||||
TargetEntry *te = nth(grpColIdx[grpno] - 1, sort_tlist);
|
||||
Resdom *resdom = te->resdom;
|
||||
|
||||
/*
|
||||
@ -1509,6 +1510,7 @@ make_groupsortplan(Query *parse,
|
||||
resdom->reskey = ++keyno;
|
||||
resdom->reskeyop = grpcl->sortop;
|
||||
}
|
||||
grpno++;
|
||||
}
|
||||
|
||||
Assert(keyno > 0);
|
||||
|
Reference in New Issue
Block a user