mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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
This commit is contained in:
@ -4781,6 +4781,27 @@ select unreserved_test();
|
||||
43
|
||||
(1 row)
|
||||
|
||||
create or replace function unreserved_test() returns int as $$
|
||||
declare
|
||||
comment int := 21;
|
||||
begin
|
||||
comment := comment * 2;
|
||||
comment on function unreserved_test() is 'this is a test';
|
||||
return comment;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
select unreserved_test();
|
||||
unreserved_test
|
||||
-----------------
|
||||
42
|
||||
(1 row)
|
||||
|
||||
select obj_description('unreserved_test()'::regprocedure, 'pg_proc');
|
||||
obj_description
|
||||
-----------------
|
||||
this is a test
|
||||
(1 row)
|
||||
|
||||
drop function unreserved_test();
|
||||
--
|
||||
-- Test FOREACH over arrays
|
||||
|
@ -3892,6 +3892,20 @@ $$ language plpgsql;
|
||||
|
||||
select unreserved_test();
|
||||
|
||||
create or replace function unreserved_test() returns int as $$
|
||||
declare
|
||||
comment int := 21;
|
||||
begin
|
||||
comment := comment * 2;
|
||||
comment on function unreserved_test() is 'this is a test';
|
||||
return comment;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
|
||||
select unreserved_test();
|
||||
|
||||
select obj_description('unreserved_test()'::regprocedure, 'pg_proc');
|
||||
|
||||
drop function unreserved_test();
|
||||
|
||||
--
|
||||
|
Reference in New Issue
Block a user