Fold plpgsql identifiers the way Postgres does - #3223
Conversation
Declarations were already folded but references used the source text as written. `DECLARE MyVar` was unreachable as `MYVAR`, quoted declarations and references were poorly handled, and a trigger body could not write `new`/`old` in lowercase because TriggerCall had registered the identifiers as as `NEW`/`OLD`. Fold variable names at reference sites in the source text, including in expression references, assignment targets, RAISE arguments and EXECUTE USING arguments. Correspondingly register lowercase names for `NEW`/`OLD` and `TG_` variables. We needed to add variable name quoting in the two places where the engine generates SQL that mentions a variable whose declared name we already hold: the integer FOR loop's condition and increment, and the CASE temporary.
|
|
SummaryCoverage spans database function behavior across normal flows, identifier casing, variable scope, record and trigger handling, conditional branches, dynamic SQL, error reporting, transaction rollback, and loop boundary cases. It also includes adversarial checks for invalid trigger actions, parameter mismatches, failed operations, and concurrent session isolation, with the exercised behavior broadly healthy aside from unrelated pre-existing defects. Safe to merge — the observed failures are medium-severity, unrelated database-engine defects and are explicitly not attributable to this PR, with no regressions or newly introduced failures identified. They are appropriate for follow-up rather than merge blockers. Tests run by ItoAdditional Findings DetailsThese findings are unrelated to the current changes but were observed during testing. 🟡 Nested variable value leaks after block ends
Evidence Package🟡 Insert triggers cannot read operation metadata
Evidence PackageTip Reply with @itoqa to send us feedback on this test run. |
|
@reltuk DOLT
|

Declarations were already folded but references used the source text as written.
DECLARE MyVarwas unreachable asMYVAR, quoted declarations and references were poorly handled, and a trigger body could not writenew/oldin lowercase because TriggerCall had registered the identifiers asNEW/OLD.Fold variable names at reference sites in the source text, including in expression references, assignment targets, RAISE arguments and EXECUTE USING arguments. Correspondingly register lowercase names for
NEW/OLDandTG_variables.We needed to add variable name quoting in the two places where the engine generates SQL that mentions a variable whose declared name we already hold: the integer FOR loop's condition and increment, and the CASE temporary.