diff options
author | Tom Lane | 2007-07-16 17:01:11 +0000 |
---|---|---|
committer | Tom Lane | 2007-07-16 17:01:11 +0000 |
commit | ae1b7e298cd99e808ec8410a808fcb2e44f8520e (patch) | |
tree | 376b2467d687762eb59c7d74e3b9a3deca18009f /src/test | |
parent | 9f6f51d5d45444c1459ec9564c29a3c205d689f6 (diff) |
Allow plpgsql function parameter names to be qualified with the function's
name. With this patch, it is always possible for the user to qualify a
plpgsql variable name if needed to avoid ambiguity. While there is much more
work to be done in this area, this simple change removes one unnecessary
incompatibility with Oracle. Per discussion.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/plpgsql.out | 28 | ||||
-rw-r--r-- | src/test/regress/sql/plpgsql.sql | 22 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index ddb44a72527..6d97b63e5c9 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -3051,3 +3051,31 @@ select * from sc_test(); (3 rows) drop function sc_test(); +-- test qualified variable names +create function pl_qual_names (param1 int) returns void as $$ +<<outerblock>> +declare + param1 int := 1; +begin + <<innerblock>> + declare + param1 int := 2; + begin + raise notice 'param1 = %', param1; + raise notice 'pl_qual_names.param1 = %', pl_qual_names.param1; + raise notice 'outerblock.param1 = %', outerblock.param1; + raise notice 'innerblock.param1 = %', innerblock.param1; + end; +end; +$$ language plpgsql; +select pl_qual_names(42); +NOTICE: param1 = 2 +NOTICE: pl_qual_names.param1 = 42 +NOTICE: outerblock.param1 = 1 +NOTICE: innerblock.param1 = 2 + pl_qual_names +--------------- + +(1 row) + +drop function pl_qual_names(int); diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index ee9de0a5838..d1c715e8d4c 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -2535,3 +2535,25 @@ select * from sc_test(); drop function sc_test(); +-- test qualified variable names + +create function pl_qual_names (param1 int) returns void as $$ +<<outerblock>> +declare + param1 int := 1; +begin + <<innerblock>> + declare + param1 int := 2; + begin + raise notice 'param1 = %', param1; + raise notice 'pl_qual_names.param1 = %', pl_qual_names.param1; + raise notice 'outerblock.param1 = %', outerblock.param1; + raise notice 'innerblock.param1 = %', innerblock.param1; + end; +end; +$$ language plpgsql; + +select pl_qual_names(42); + +drop function pl_qual_names(int); |