Fix SQL:2008 FETCH FIRST syntax to allow parameters.

Andrew Gierth <rhodiumtoad@postgresql.org>

Commit: 3b0fb2529fdfc4632c9d61194ecd6f8551c38309
Author: Andrew Gierth <rhodiumtoad@postgresql.org>
Date: 2018-05-21T16:32:24Z
Releases: 9.5.14
Fix SQL:2008 FETCH FIRST syntax to allow parameters.

OFFSET <x> ROWS FETCH FIRST <y> ROWS ONLY syntax is supposed to accept
<simple value specification>, which includes parameters as well as
literals. When this syntax was added all those years ago, it was done
inconsistently, with <x> and <y> being different subsets of the
standard syntax.

Rectify that by making <x> and <y> 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

Files

PathChange+/−
doc/src/sgml/ref/select.sgml modified +8 −6
src/backend/parser/gram.y modified +33 −16

Discussion