diff options
| author | Tom Lane | 2009-12-15 17:57:48 +0000 |
|---|---|---|
| committer | Tom Lane | 2009-12-15 17:57:48 +0000 |
| commit | 34d26872ed816b299eef2fa4240d55316697f42d (patch) | |
| tree | d7373e29b365c151702c44325f0f5cc9dcc3e17c /src/backend/parser/analyze.c | |
| parent | 6a6efb964092902bf53965649c3ed78b1868b37e (diff) | |
Support ORDER BY within aggregate function calls, at long last providing a
non-kluge method for controlling the order in which values are fed to an
aggregate function. At the same time eliminate the old implementation
restriction that DISTINCT was only supported for single-argument aggregates.
Possibly release-notable behavioral change: formerly, agg(DISTINCT x)
dropped null values of x unconditionally. Now, it does so only if the
agg transition function is strict; otherwise nulls are treated as DISTINCT
normally would, ie, you get one copy.
Andrew Gierth, reviewed by Hitoshi Harada
Diffstat (limited to 'src/backend/parser/analyze.c')
| -rw-r--r-- | src/backend/parser/analyze.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 49ec8481846..0f47e7bae9b 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.396 2009/10/31 01:41:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.397 2009/12/15 17:57:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -828,13 +828,13 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) stmt->sortClause, &qry->targetList, true /* fix unknowns */, - false /* not window function */); + false /* allow SQL92 rules */); qry->groupClause = transformGroupClause(pstate, stmt->groupClause, &qry->targetList, qry->sortClause, - false /* not window function */); + false /* allow SQL92 rules */); if (stmt->distinctClause == NIL) { @@ -846,7 +846,8 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) /* We had SELECT DISTINCT */ qry->distinctClause = transformDistinctClause(pstate, &qry->targetList, - qry->sortClause); + qry->sortClause, + false); qry->hasDistinctOn = false; } else @@ -1044,7 +1045,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt) stmt->sortClause, &qry->targetList, true /* fix unknowns */, - false /* not window function */); + false /* allow SQL92 rules */); qry->limitOffset = transformLimitClause(pstate, stmt->limitOffset, "OFFSET"); @@ -1298,7 +1299,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) sortClause, &qry->targetList, false /* no unknowns expected */, - false /* not window function */); + false /* allow SQL92 rules */); pstate->p_rtable = list_truncate(pstate->p_rtable, sv_rtable_length); pstate->p_relnamespace = sv_relnamespace; |
