Commit 15a5006a authored by Tom Lane's avatar Tom Lane

Clarify documentation about SQL:2008 variant of LIMIT/OFFSET syntax.

The point that you need parentheses for non-constant expressions apparently
needs to be brought out a bit more clearly, per bug #6315.
parent 3b86b465
...@@ -1064,7 +1064,8 @@ SELECT name FROM distributors ORDER BY code; ...@@ -1064,7 +1064,8 @@ SELECT name FROM distributors ORDER BY code;
<synopsis> <synopsis>
LIMIT { <replaceable class="parameter">count</replaceable> | ALL } LIMIT { <replaceable class="parameter">count</replaceable> | ALL }
OFFSET <replaceable class="parameter">start</replaceable> OFFSET <replaceable class="parameter">start</replaceable>
</synopsis><replaceable class="parameter">count</replaceable> specifies the </synopsis>
<replaceable class="parameter">count</replaceable> specifies the
maximum number of rows to return, while <replaceable maximum number of rows to return, while <replaceable
class="parameter">start</replaceable> specifies the number of rows class="parameter">start</replaceable> specifies the number of rows
to skip before starting to return rows. When both are specified, to skip before starting to return rows. When both are specified,
...@@ -1087,17 +1088,19 @@ OFFSET <replaceable class="parameter">start</replaceable> ...@@ -1087,17 +1088,19 @@ OFFSET <replaceable class="parameter">start</replaceable>
OFFSET <replaceable class="parameter">start</replaceable> { ROW | ROWS } OFFSET <replaceable class="parameter">start</replaceable> { ROW | ROWS }
FETCH { FIRST | NEXT } [ <replaceable class="parameter">count</replaceable> ] { ROW | ROWS } ONLY FETCH { FIRST | NEXT } [ <replaceable class="parameter">count</replaceable> ] { ROW | ROWS } ONLY
</synopsis> </synopsis>
According to the standard, the <literal>OFFSET</literal> clause must come In this syntax, to write anything except a simple integer constant for
before the <literal>FETCH</literal> clause if both are present; but <replaceable class="parameter">start</> or <replaceable
<productname>PostgreSQL</> is laxer and allows either order. class="parameter">count</replaceable>, you must write parentheses
around it.
If <replaceable class="parameter">count</> is
omitted in a <literal>FETCH</> clause, it defaults to 1.
<literal>ROW</literal> <literal>ROW</literal>
and <literal>ROWS</literal> as well as <literal>FIRST</literal> and <literal>ROWS</literal> as well as <literal>FIRST</literal>
and <literal>NEXT</literal> are noise words that don't influence and <literal>NEXT</literal> are noise words that don't influence
the effects of these clauses. In this syntax, when using expressions the effects of these clauses.
other than simple constants for <replaceable class="parameter">start</> According to the standard, the <literal>OFFSET</literal> clause must come
or <replaceable class="parameter">count</replaceable>, parentheses will be before the <literal>FETCH</literal> clause if both are present; but
necessary in most cases. If <replaceable class="parameter">count</> is <productname>PostgreSQL</> is laxer and allows either order.
omitted in <literal>FETCH</>, it defaults to 1.
</para> </para>
<para> <para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment