postgresql/src/pl/plpgsql/src/expected
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
..
plpgsql_array.out In plpgsql, allow %TYPE and %ROWTYPE to be followed by array decoration. 2024-01-04 15:24:15 -05:00
plpgsql_cache.out Rename debug_invalidate_system_caches_always to debug_discard_caches. 2021-07-13 15:01:01 -04:00
plpgsql_cache_1.out Rename debug_invalidate_system_caches_always to debug_discard_caches. 2021-07-13 15:01:01 -04:00
plpgsql_call.out Collect dependency information for parsed CallStmts. 2023-09-25 14:42:17 -04:00
plpgsql_control.out Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
plpgsql_copy.out Remove dynamic translation of regression test scripts, step 2. 2021-12-20 14:15:52 -05:00
plpgsql_domain.out plpgsql: report proper line number for errors in variable initialization. 2021-10-31 12:43:47 -04:00
plpgsql_misc.out Improve plpgsql's error messages for incorrect %TYPE and %ROWTYPE. 2024-02-28 16:05:28 -05:00
plpgsql_record.out Clean up some edge cases in plpgsql's %TYPE parsing. 2024-01-05 14:32:34 -05:00
plpgsql_simple.out Fix corner-case uninitialized-variable issues in plpgsql. 2021-07-20 13:01:48 -04:00
plpgsql_transaction.out Introduce GUC_NO_RESET flag. 2022-09-27 11:47:12 -04:00
plpgsql_trap.out Allow underscores in integer and numeric constants. 2023-02-04 09:48:51 +00:00
plpgsql_trigger.out Update docs & tests to reflect that unassigned OLD/NEW are now NULL. 2019-01-09 11:35:14 -05:00
plpgsql_varprops.out plpgsql: report proper line number for errors in variable initialization. 2021-10-31 12:43:47 -04:00