mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +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:
parent
706a32cdf6
commit
6c4996fa6b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user