From cf516dc9d69052360f1de390636c220797120d28 Mon Sep 17 00:00:00 2001 From: Andrew Gierth Date: Mon, 21 May 2018 17:02:17 +0100 Subject: Fix SQL:2008 FETCH FIRST syntax to allow parameters. OFFSET ROWS FETCH FIRST ROWS ONLY syntax is supposed to accept , which includes parameters as well as literals. When this syntax was added all those years ago, it was done inconsistently, with and being different subsets of the standard syntax. Rectify that by making and accept the same thing, and allowing either a (signed) numeric literal or a c_expr there, which allows for parameters, variables, and parenthesized arbitrary expressions. Per bug #15200 from Lukas Eder. Backpatch all the way, since this has been broken from the start. Discussion: https://postgr.es/m/877enz476l.fsf@news-spur.riddles.org.uk Discussion: http://postgr.es/m/152647780335.27204.16895288237122418685@wrigleys.postgresql.org --- doc/src/sgml/ref/select.sgml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index 57f11e66fb6..4c8b6f1e73d 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -1349,12 +1349,14 @@ OFFSET start OFFSET start { ROW | ROWS } FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY - In this syntax, to write anything except a simple integer constant for - start or count, you must write parentheses - around it. - If count is - omitted in a FETCH clause, it defaults to 1. + In this syntax, the start + or count value is required by + the standard to be a literal constant, a parameter, or a variable name; + as a PostgreSQL extension, other expressions + are allowed, but will generally need to be enclosed in parentheses to avoid + ambiguity. + 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 -- cgit v1.2.3