mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Modify the definition of window-function PARTITION BY and ORDER BY clauses
so that their elements are always taken as simple expressions over the query's input columns. It originally seemed like a good idea to make them act exactly like GROUP BY and ORDER BY, right down to the SQL92-era behavior of accepting output column names or numbers. However, that was not such a great idea, for two reasons: 1. It permits circular references, as exhibited in bug #5018: the output column could be the one containing the window function itself. (We actually had a regression test case illustrating this, but nobody thought twice about how confusing that would be.) 2. It doesn't seem like a good idea for, eg, "lead(foo) OVER (ORDER BY foo)" to potentially use two completely different meanings for "foo". Accordingly, narrow down the behavior of window clauses to use only the SQL99-compliant interpretation that the expressions are simple expressions.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.133 2009/06/17 21:58:49 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.134 2009/08/27 20:08:02 tgl Exp $ -->
|
||||
|
||||
<chapter id="sql-syntax">
|
||||
<title>SQL Syntax</title>
|
||||
@@ -1619,7 +1619,9 @@ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
expression that does not itself contain window function calls.
|
||||
The <literal>PARTITION BY</> and <literal>ORDER BY</> lists have
|
||||
essentially the same syntax and semantics as <literal>GROUP BY</>
|
||||
and <literal>ORDER BY</> clauses of the whole query.
|
||||
and <literal>ORDER BY</> clauses of the whole query, except that their
|
||||
expressions are always just expressions and cannot be output-column
|
||||
names or numbers.
|
||||
<replaceable>window_name</replaceable> is a reference to a named window
|
||||
specification defined in the query's <literal>WINDOW</literal> clause.
|
||||
Named window specifications are usually referenced with just
|
||||
|
Reference in New Issue
Block a user