summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane2008-12-31 23:42:56 +0000
committerTom Lane2008-12-31 23:42:56 +0000
commitdf0ea5a1cdc9b5a8ed172124818d42a9d33bc971 (patch)
tree12735480ffa5e81096917aef28f1f763f30f8869 /doc/src
parenteb273743ed741e5c8216dd91955612a94fd7022d (diff)
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 'doc/src')
-rw-r--r--doc/src/sgml/ref/select.sgml11
-rw-r--r--doc/src/sgml/syntax.sgml19
2 files changed, 18 insertions, 12 deletions
diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml
index ba8bff0e523..0a19f894e70 100644
--- a/doc/src/sgml/ref/select.sgml
+++ b/doc/src/sgml/ref/select.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.115 2008/12/31 00:08:35 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.116 2008/12/31 23:42:56 tgl Exp $
PostgreSQL documentation
-->
@@ -583,7 +583,7 @@ WINDOW <replaceable class="parameter">window_name</replaceable> AS ( <replaceabl
[ <replaceable class="parameter">existing_window_name</replaceable> ]
[ PARTITION BY <replaceable class="parameter">expression</replaceable> [, ...] ]
[ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC | USING <replaceable class="parameter">operator</replaceable> ] [ NULLS { FIRST | LAST } ] [, ...] ]
-[ <replaceable class="parameter">framing_clause</replaceable> ]
+[ <replaceable class="parameter">frame_clause</replaceable> ]
</synopsis>
</para>
@@ -594,7 +594,8 @@ WINDOW <replaceable class="parameter">window_name</replaceable> AS ( <replaceabl
as well as its ordering clause if any. In this case the new window cannot
specify its own <literal>PARTITION BY</> clause, and it can specify
<literal>ORDER BY</> only if the copied window does not have one.
- The framing clause is never copied from the existing window.
+ The new window always uses its own frame clause; the copied window
+ must not specify a frame clause.
</para>
<para>
@@ -611,7 +612,7 @@ WINDOW <replaceable class="parameter">window_name</replaceable> AS ( <replaceabl
</para>
<para>
- The optional <replaceable class="parameter">framing_clause</> defines
+ The optional <replaceable class="parameter">frame_clause</> defines
the <firstterm>window frame</> for window functions that depend on the
frame (not all do). It can be one of
<synopsis>
@@ -1486,7 +1487,7 @@ SELECT distributors.* WHERE distributors.name = 'Westward';
<para>
The SQL standard provides additional options for the window
- <replaceable class="parameter">framing_clause</>.
+ <replaceable class="parameter">frame_clause</>.
<productname>PostgreSQL</productname> currently supports only the
options listed above.
</para>
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 327bdd7f0f4..6165259a838 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.128 2008/12/31 00:08:35 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.129 2008/12/31 23:42:56 tgl Exp $ -->
<chapter id="sql-syntax">
<title>SQL Syntax</title>
@@ -1588,12 +1588,12 @@ sqrt(2)
where <replaceable class="parameter">window_definition</replaceable>
has the syntax
<synopsis>
-[ <replaceable class="parameter">window_name</replaceable> ]
+[ <replaceable class="parameter">existing_window_name</replaceable> ]
[ PARTITION BY <replaceable class="parameter">expression</replaceable> [, ...] ]
[ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC | USING <replaceable class="parameter">operator</replaceable> ] [ NULLS { FIRST | LAST } ] [, ...] ]
-[ <replaceable class="parameter">framing_clause</replaceable> ]
+[ <replaceable class="parameter">frame_clause</replaceable> ]
</synopsis>
- and the optional <replaceable class="parameter">framing_clause</replaceable>
+ and the optional <replaceable class="parameter">frame_clause</replaceable>
can be one of
<synopsis>
RANGE UNBOUNDED PRECEDING
@@ -1614,7 +1614,8 @@ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
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 override its ordering clause and/or framing clause.
+ 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" endterm="sql-select-title"> reference
@@ -1622,6 +1623,9 @@ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
</para>
<para>
+ The <replaceable class="parameter">frame_clause</replaceable> specifies
+ the set of rows constituting the <firstterm>window frame</>, for those
+ window functions that act on the frame instead of the whole partition.
The default framing option is <literal>RANGE UNBOUNDED PRECEDING</>,
which is the same as <literal>RANGE BETWEEN UNBOUNDED PRECEDING AND
CURRENT ROW</>; it selects rows up through the current row's last
@@ -1639,8 +1643,9 @@ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
<para>
The built-in window functions are described in <xref
- linkend="functions-window-table">. Also, any built-in or
- user-defined aggregate function can be used as a window function.
+ linkend="functions-window-table">. Other window functions can be added by
+ the user. Also, any built-in or user-defined aggregate function can be
+ used as a window function.
</para>
<para>