Fix for FETCH FIRST syntax problems
Andrew Gierth <andrew@tao11.riddles.org.uk>
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: pgsql-hackers@postgresql.org
Date: 2018-05-19T22:33:22Z
Lists: pgsql-hackers
Attachments
- ff.patch (text/x-patch) patch
Per bug #15200, our support for sql2008 FETCH FIRST syntax is incomplete to the extent that it should be regarded as a bug; the spec quite clearly allows parameters/host variables in addition to constants, but we don't. Attached is a draft patch for fixing that, which additionally fixes the ugly wart that OFFSET <x> ROW/ROWS and FETCH FIRST [<x>] ROW/ROWS ONLY had very different productions for <x>; both now accept c_expr there. Shift/reduce conflict is avoided by taking advantage of the fact that ONLY is a fully reserved word. I've checked that this change would not make it any harder to add (post-2008 features) WITH TIES or PERCENT in the event that someone wants to do that. I think a case can be made that this should be backpatched; thoughts? (While I can't find any visible change for existing working queries, one change that does occur is that FETCH FIRST -1 ROWS ONLY now returns a different error message; but that was already inconsistent with the error from OFFSET -1 ROWS.) -- Andrew (irc:RhodiumToad)
Commits
-
Fix SQL:2008 FETCH FIRST syntax to allow parameters.
- 89b09db01b43 9.3.24 landed
- 769e6fcd1a35 9.4.19 landed
- 3b0fb2529fdf 9.5.14 landed
- 7a0aa8d12ace 9.6.10 landed
- cf516dc9d690 10.5 landed
- 1da162e1f5a7 11.0 landed
-
SQL:2008 alternative syntax for LIMIT/OFFSET:
- 361bfc35724a 8.4.0 cited