diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-12-31 23:42:56 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-12-31 23:42:56 +0000 |
commit | df0ea5a1cdc9b5a8ed172124818d42a9d33bc971 (patch) | |
tree | 12735480ffa5e81096917aef28f1f763f30f8869 /src/backend | |
parent | eb273743ed741e5c8216dd91955612a94fd7022d (diff) | |
download | postgresql-df0ea5a1cdc9b5a8ed172124818d42a9d33bc971.tar.gz |
Throw error if a <window definition> references a window that already has a
frame clause, as appears to be required by the fine print in the SQL spec.
Per discussion with Pavel, not doing so risks user confusion.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/parser/parse_clause.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 247d54d878..3e52ce6c33 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.183 2008/12/31 00:08:37 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.184 2008/12/31 23:42:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1554,7 +1554,10 @@ transformWindowDefinitions(ParseState *pstate, * Per spec, a windowdef that references a previous one copies the * previous partition clause (and mustn't specify its own). It can * specify its own ordering clause. but only if the previous one - * had none. It always specifies its own framing clause. + * had none. It always specifies its own frame clause, and the + * previous one must not have a frame clause. (Yeah, it's bizarre + * that each of these cases works differently, but SQL:2008 says so; + * see 7.11 <window clause> syntax rule 10 and general rule 1.) */ if (refwc) { @@ -1592,6 +1595,12 @@ transformWindowDefinitions(ParseState *pstate, wc->orderClause = orderClause; wc->copiedOrder = false; } + if (refwc && refwc->frameOptions != FRAMEOPTION_DEFAULTS) + ereport(ERROR, + (errcode(ERRCODE_WINDOWING_ERROR), + errmsg("cannot override frame clause of window \"%s\"", + windef->refname), + parser_errposition(pstate, windef->location))); wc->frameOptions = windef->frameOptions; wc->winref = winref; |