summaryrefslogtreecommitdiff
path: root/src/backend/parser/analyze.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r--src/backend/parser/analyze.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 9ac8132f08..95b209e4ac 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.273 2003/06/06 15:04:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.274 2003/06/15 16:42:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1787,14 +1787,19 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
*/
qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
- qry->groupClause = transformGroupClause(pstate,
- stmt->groupClause,
- qry->targetList);
-
+ /*
+ * Transform sorting/grouping stuff. Do ORDER BY first because both
+ * transformGroupClause and transformDistinctClause need the results.
+ */
qry->sortClause = transformSortClause(pstate,
stmt->sortClause,
qry->targetList);
+ qry->groupClause = transformGroupClause(pstate,
+ stmt->groupClause,
+ qry->targetList,
+ qry->sortClause);
+
qry->distinctClause = transformDistinctClause(pstate,
stmt->distinctClause,
qry->targetList,