Support plpgsql variable names that conflict with unreserved SQL keywords.
Tom Lane <tgl@sss.pgh.pa.us>
Support plpgsql variable names that conflict with unreserved SQL keywords. A variable name matching a statement-introducing keyword, such as "comment" or "update", caused parse failures if one tried to write a statement using that keyword. Commit bb1b8f69 already addressed this scenario for the case of variable names matching unreserved plpgsql keywords, but we didn't think about unreserved core-grammar keywords. The same heuristic (viz, it can't be a variable name unless the next token is assignment or '[') should work fine for that case too, and as a bonus the code gets shorter and less duplicative. Per bug #15555 from Feike Steenbergen. Since this hasn't been complained of before, and is easily worked around anyway, I won't risk a back-patch. Discussion: https://postgr.es/m/15555-149bbd70ddc7b4b6@postgresql.org
Files
| Path | Change | +/− |
|---|---|---|
| src/pl/plpgsql/src/pl_comp.c | modified | +8 −5 |
| src/pl/plpgsql/src/plpgsql.h | modified | +1 −1 |
| src/pl/plpgsql/src/pl_scanner.c | modified | +31 −43 |
| src/test/regress/expected/plpgsql.out | modified | +21 −0 |
| src/test/regress/sql/plpgsql.sql | modified | +14 −0 |
Discussion
- BUG #15555: Syntax errors when using the COMMENT command in plpgsql and a "comment" variable 6 messages · 2018-12-17 → 2019-01-04