mirror of
https://github.com/postgres/postgres.git
synced 2026-01-27 21:43:08 +03:00
Need to do SPI_push/SPI_pop around expression evaluation in plpgsql.
We must do this in case the expression evaluation results in calling
another plpgsql function (or, really, anything using SPI). I missed
the need for this when I converted exec_cast_value() from doing a
simple InputFunctionCall() to doing ExecEvalExpr() in commit 1345cc67b.
There is a SPI_push_conditional in InputFunctionCall(), so that there
was no bug before that.
Per bug #14414 from Marcos Castedo. Add a regression test based on his
example, which was that a plpgsql function in a domain check constraint
didn't work when assigning to a domain-type variable within plpgsql.
Report: <20161106010947.1387.66380@wrigleys.postgresql.org>
This commit is contained in:
@@ -4428,3 +4428,25 @@ exception when others then
|
||||
null; -- do nothing
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- Test use of plpgsql in a domain check constraint (cf. bug #14414)
|
||||
|
||||
create function plpgsql_domain_check(val int) returns boolean as $$
|
||||
begin return val > 0; end
|
||||
$$ language plpgsql immutable;
|
||||
|
||||
create domain plpgsql_domain as integer check(plpgsql_domain_check(value));
|
||||
|
||||
do $$
|
||||
declare v_test plpgsql_domain;
|
||||
begin
|
||||
v_test := 1;
|
||||
end;
|
||||
$$;
|
||||
|
||||
do $$
|
||||
declare v_test plpgsql_domain := 1;
|
||||
begin
|
||||
v_test := 0; -- fail
|
||||
end;
|
||||
$$;
|
||||
|
||||
Reference in New Issue
Block a user