summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane2013-11-06 02:58:16 +0000
committerTom Lane2013-11-06 02:58:16 +0000
commit599942cf49d747ce4f1baabe10dc62690810bca3 (patch)
tree5bab5ebb888dddc09f9e846d8e935825576279e4 /doc/src
parent85de126246cd44315965c08f4af3d7d75fb9c5f1 (diff)
Improve the error message given for modifying a window with frame clause.
For rather inscrutable reasons, SQL:2008 disallows copying-and-modifying a window definition that has any explicit framing clause. The error message we gave for this only made sense if the referencing window definition itself contains an explicit framing clause, which it might well not. Moreover, in the context of an OVER clause it's not exactly obvious that "OVER (windowname)" implies copy-and-modify while "OVER windowname" does not. This has led to multiple complaints, eg bug #5199 from Iliya Krapchatov. Change to a hopefully more intelligible error message, and in the case where we have just "OVER (windowname)", add a HINT suggesting that omitting the parentheses will fix it. Also improve the related documentation. Back-patch to all supported branches.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/syntax.sgml21
1 files changed, 10 insertions, 11 deletions
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 43df81e7648..8d8a1e91fc3 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -1709,10 +1709,10 @@ SELECT string_agg(a ORDER BY a, ',') FROM table; -- incorrect
The syntax of a window function call is one of the following:
<synopsis>
-<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) OVER ( <replaceable class="parameter">window_definition</replaceable> )
<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) OVER <replaceable>window_name</replaceable>
-<replaceable>function_name</replaceable> ( * ) OVER ( <replaceable class="parameter">window_definition</replaceable> )
+<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) OVER ( <replaceable class="parameter">window_definition</replaceable> )
<replaceable>function_name</replaceable> ( * ) OVER <replaceable>window_name</replaceable>
+<replaceable>function_name</replaceable> ( * ) OVER ( <replaceable class="parameter">window_definition</replaceable> )
</synopsis>
where <replaceable class="parameter">window_definition</replaceable>
has the syntax
@@ -1749,15 +1749,14 @@ UNBOUNDED FOLLOWING
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
- <literal>OVER</> <replaceable>window_name</replaceable>, but it is
- also possible to write a window name inside the parentheses and then
- optionally supply an ordering clause and/or frame clause (the referenced
- window must lack these clauses, if they are supplied here).
- This latter syntax follows the same rules as modifying an existing
- window name within the <literal>WINDOW</literal> clause; see the
- <xref linkend="sql-select"> reference
- page for details.
+ Alternatively, a full <replaceable>window_definition</replaceable> can
+ be given within parentheses, using the same syntax as for defining a
+ named window in the <literal>WINDOW</literal> clause; see the
+ <xref linkend="sql-select"> reference page for details. It's worth
+ pointing out that <literal>OVER wname</> is not exactly equivalent to
+ <literal>OVER (wname)</>; the latter implies copying and modifying the
+ window definition, and will be rejected if the referenced window
+ specification includes a frame clause.
</para>
<para>