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:
Tom Lane 2003-03-13 16:58:35 +00:00
parent 706a32cdf6
commit 6c4996fa6b
1 changed files with 4 additions and 2 deletions

View File

@ -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);