From 1da162e1f5a783bd0ce26e6a07c0138dc8a47d44 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index b5d3d3a071e..3d59b0c3e5a 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -1399,10 +1399,12 @@ 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. + 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 -- cgit v1.2.3