1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Support CONSTANT/NOT NULL/initial value for plpgsql composite variables.

These features were never implemented previously for composite or record
variables ... not that the documentation admitted it, so there's no doc
updates here.

This also fixes some issues concerning enforcing DOMAIN NOT NULL
constraints against plpgsql variables, although I'm not sure that
that topic is completely dealt with.

I created a new plpgsql test file for these features, and moved the
one relevant existing test case into that file.

Tom Lane, reviewed by Daniel Gustafsson

Discussion: https://postgr.es/m/18362.1514605650@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2018-02-13 22:15:08 -05:00
parent fd333bc763
commit f9263006d8
10 changed files with 686 additions and 134 deletions

View File

@ -4586,42 +4586,6 @@ select scope_test();
(1 row)
drop function scope_test();
-- Check that variables are reinitialized on block re-entry.
\set VERBOSITY terse \\ -- needed for output stability
do $$
begin
for i in 1..3 loop
declare
x int;
y int := i;
r record;
c int8_tbl;
begin
if i = 1 then
x := 42;
r := row(i, i+1);
c := row(i, i+1);
end if;
raise notice 'x = %', x;
raise notice 'y = %', y;
raise notice 'r = %', r;
raise notice 'c = %', c;
end;
end loop;
end$$;
NOTICE: x = 42
NOTICE: y = 1
NOTICE: r = (1,2)
NOTICE: c = (1,2)
NOTICE: x = <NULL>
NOTICE: y = 2
NOTICE: r = <NULL>
NOTICE: c = <NULL>
NOTICE: x = <NULL>
NOTICE: y = 3
NOTICE: r = <NULL>
NOTICE: c = <NULL>
\set VERBOSITY default
-- Check handling of conflicts between plpgsql vars and table columns.
set plpgsql.variable_conflict = error;
create function conflict_test() returns setof int8_tbl as $$

View File

@ -3735,32 +3735,6 @@ select scope_test();
drop function scope_test();
-- Check that variables are reinitialized on block re-entry.
\set VERBOSITY terse \\ -- needed for output stability
do $$
begin
for i in 1..3 loop
declare
x int;
y int := i;
r record;
c int8_tbl;
begin
if i = 1 then
x := 42;
r := row(i, i+1);
c := row(i, i+1);
end if;
raise notice 'x = %', x;
raise notice 'y = %', y;
raise notice 'r = %', r;
raise notice 'c = %', c;
end;
end loop;
end$$;
\set VERBOSITY default
-- Check handling of conflicts between plpgsql vars and table columns.
set plpgsql.variable_conflict = error;