1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-11 00:12:06 +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:
Tom Lane
2003-03-13 16:58:49 +00:00
parent db825e3743
commit d144f96bf0

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.125.2.2 2003/03/05 18:38:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.125.2.3 2003/03/13 16:58:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1498,13 +1498,14 @@ make_groupplan(Query *parse,
* are just dummies with no extra execution cost.)
*/
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;
/*
@@ -1518,6 +1519,7 @@ make_groupplan(Query *parse,
resdom->reskey = ++keyno;
resdom->reskeyop = grpcl->sortop;
}
grpno++;
}
Assert(keyno > 0);