mirror of
https://github.com/postgres/postgres.git
synced 2025-06-06 00:02:36 -04:00
Fix GROUP BY when order of entries is different from order in target list.
This commit is contained in:
parent
bb0cc20e64
commit
c42f7f1460
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.7 1997/09/08 21:45:24 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.8 1997/09/25 12:21:15 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -394,7 +394,6 @@ make_groupPlan(List **tlist,
|
|||||||
Group *grpplan;
|
Group *grpplan;
|
||||||
int numCols;
|
int numCols;
|
||||||
AttrNumber *grpColIdx;
|
AttrNumber *grpColIdx;
|
||||||
int keyno = 1;
|
|
||||||
int last_resno = 1;
|
int last_resno = 1;
|
||||||
|
|
||||||
numCols = length(groupClause);
|
numCols = length(groupClause);
|
||||||
@ -412,13 +411,15 @@ make_groupPlan(List **tlist,
|
|||||||
*/
|
*/
|
||||||
foreach(sl, sort_tlist)
|
foreach(sl, sort_tlist)
|
||||||
{
|
{
|
||||||
Resdom *resdom = NULL;
|
Resdom *resdom = NULL;
|
||||||
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
TargetEntry *te = (TargetEntry *) lfirst(sl);
|
||||||
|
int keyno = 0;
|
||||||
|
|
||||||
foreach(gl, glc)
|
foreach(gl, groupClause)
|
||||||
{
|
{
|
||||||
GroupClause *grpcl = (GroupClause *) lfirst(gl);
|
GroupClause *grpcl = (GroupClause *) lfirst(gl);
|
||||||
|
|
||||||
|
keyno++;
|
||||||
if (grpcl->entry->resdom->resno == te->resdom->resno)
|
if (grpcl->entry->resdom->resno == te->resdom->resno)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -427,7 +428,6 @@ make_groupPlan(List **tlist,
|
|||||||
resdom->reskeyop = get_opcode(grpcl->grpOpoid);
|
resdom->reskeyop = get_opcode(grpcl->grpOpoid);
|
||||||
resdom->resno = last_resno; /* re-set */
|
resdom->resno = last_resno; /* re-set */
|
||||||
grpColIdx[keyno - 1] = last_resno++;
|
grpColIdx[keyno - 1] = last_resno++;
|
||||||
keyno++;
|
|
||||||
glc = lremove(lfirst(gl), glc); /* TLE found for it */
|
glc = lremove(lfirst(gl), glc); /* TLE found for it */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user