postgresql/src
Tom Lane 5392dd3d2a Fix plpgsql's handling of -- comments following expressions.
Up to now, read_sql_construct() has collected all the source text from
the statement or expression's initial token up to the character just
before the "until" token.  It normally tries to strip trailing
whitespace from that, largely for neatness.  If there was a "-- text"
comment after the expression, this resulted in removing the newline
that terminates the comment, which creates a hazard if we try to paste
the collected text into a larger SQL construct without inserting a
newline after it.  In particular this caused our handling of CASE
constructs to fail if there's a comment after a WHEN expression.

Commit 4adead1d2 noticed a similar problem with cursor arguments,
and worked around it through the rather crude hack of suppressing
the whitespace-trimming behavior for those.  Rather than do that
and leave the hazard open for future hackers to trip over, let's
fix it properly.  pl_scanner.c already has enough infrastructure
to report the end location of the expression's last token, so
we can copy up to that location and never collect any trailing
whitespace or comment to begin with.

Erik Wienhold and Tom Lane, per report from Michal Bartak.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAAVzF_FjRoi8fOVuLCZhQJx6HATQ7MKm=aFOHWZODFnLmjX-xA@mail.gmail.com
2024-04-10 15:45:58 -04:00
..
backend Fix illegal attribute propagation in LLVM JIT. 2024-04-10 12:13:46 +12:00
bin Add missing set_pglocale_pgservice() for pg_walsummary and pg_combinebackup 2024-04-09 14:01:33 +09:00
common Silence some compiler warnings in commit 3311ea86ed 2024-04-05 16:08:40 -04:00
fe_utils Allow dbname to be written as part of connstring via pg_basebackup's -R option. 2024-03-21 10:50:33 +05:30
include revert: Transform OR clauses to ANY expression 2024-04-10 02:28:09 +03:00
interfaces libpq error message fixes 2024-04-09 08:06:31 +03:00
makefiles Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
pl Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
port Optimize visibilitymap_count() with AVX-512 instructions. 2024-04-06 22:58:23 -05:00
template Remove AIX support 2024-02-28 15:17:23 +04:00
test Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
timezone Update time zone data files to tzdata release 2024a. 2024-02-01 15:57:53 -05:00
tools revert: Transform OR clauses to ANY expression 2024-04-10 02:28:09 +03:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00