Clarify documentation about SQL:2008 variant of LIMIT/OFFSET syntax.
authorTom Lane
Thu, 1 Dec 2011 21:38:59 +0000 (16:38 -0500)
committerTom Lane
Thu, 1 Dec 2011 21:38:59 +0000 (16:38 -0500)
The point that you need parentheses for non-constant expressions apparently
needs to be brought out a bit more clearly, per bug #6315.

doc/src/sgml/ref/select.sgml

index cc8cd48583a59f7a3e15ba7ae799dcc3b003b30f..39fc6b6d830b34c4f6c2249127337ee59744b1fa 100644 (file)
@@ -1064,7 +1064,8 @@ SELECT name FROM distributors ORDER BY code;
 
 LIMIT { count | ALL }
 OFFSET start
-count specifies the
+
+    count specifies the
     maximum number of rows to return, while 
     class="parameter">start specifies the number of rows
     to skip before starting to return rows.  When both are specified,
@@ -1087,17 +1088,19 @@ OFFSET start
 OFFSET start { ROW | ROWS }
 FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY
 
-    According to the standard, the OFFSET clause must come
-    before the FETCH clause if both are present; but
-    PostgreSQL is laxer and allows either order.
+    In this syntax, to write anything except a simple integer constant for
+    start or 
+    class="parameter">count, you must write parentheses
+    around it.
+    If count is
+    omitted in a FETCH clause, it defaults to 1.
     ROW
     and ROWS as well as FIRST
     and NEXT are noise words that don't influence
-    the effects of these clauses.  In this syntax, when using expressions
-    other than simple constants for start
-    or count, parentheses will be
-    necessary in most cases.  If count is
-    omitted in FETCH, it defaults to 1.
+    the effects of these clauses.
+    According to the standard, the OFFSET clause must come
+    before the FETCH clause if both are present; but
+    PostgreSQL is laxer and allows either order.