postgresql/src
Heikki Linnakangas 72fe74ca53 Fix deparsing FETCH FIRST <expr> ROWS WITH TIES
In the grammar, <expr> is a c_expr, which accepts only a limited set
of integer literals and simple expressions without parens. The
deparsing logic didn't quite match the grammar rule, and failed to use
parens e.g. for "5::bigint".

To fix, always surround the expression with parens. Would be nice to
omit the parens in simple cases, but unfortunately it's non-trivial to
detect such simple cases. Even if the expression is a simple literal
123 in the original query, after parse analysis it becomes a FuncExpr
with COERCE_IMPLICIT_CAST rather than a simple Const.

Reported-by: yonghao lee
Backpatch-through: 13
Discussion: https://www.postgresql.org/message-id/18929-077d6b7093b176e2@postgresql.org
2025-05-19 18:50:52 +03:00
..
backend Fix deparsing FETCH FIRST <expr> ROWS WITH TIES 2025-05-19 18:50:52 +03:00
bin Translation updates 2025-05-05 12:20:37 +02:00
common With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:08 -07:00
fe_utils In fmtIdEnc(), handle failure of enlargePQExpBuffer(). 2025-02-16 12:46:35 -05:00
include Make our usage of memset_s() conform strictly to the C11 standard. 2025-05-18 12:45:55 -04:00
interfaces With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:08 -07:00
makefiles Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
pl Translation updates 2025-05-05 12:20:37 +02:00
port Make our usage of memset_s() conform strictly to the C11 standard. 2025-05-18 12:45:55 -04:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:28:55 -04:00
test Fix deparsing FETCH FIRST <expr> ROWS WITH TIES 2025-05-19 18:50:52 +03:00
timezone Update time zone data files to tzdata release 2025b. 2025-04-30 11:14:10 -04:00
tools Make our usage of memset_s() conform strictly to the C11 standard. 2025-05-18 12:45:55 -04:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Suppress macOS warnings about duplicate libraries in link commands. 2023-09-29 14:07:30 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk Improve frontend error logging style. 2022-04-08 14:55:14 -04:00