diff options
-rw-r--r-- | src/test/regress/expected/plpgsql.out | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 9a05a05e3e..b03423e260 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -6042,3 +6042,37 @@ SELECT * FROM list_partitioned_table() AS t; 2 (2 rows) +-- ensure that all statements in a function are correctly executed in a +-- transaction block. +create table plp_mt_tab(a int, b int); +create function plpgsql_multistmt() returns void as $$ +begin + insert into plp_mt_tab(a) values (1); + insert into plp_mt_tab(a) values (2); + insert into plp_mt_tab(a) values (3/0); +end +$$ language plpgsql; +select plpgsql_multistmt(); +ERROR: division by zero +CONTEXT: SQL statement "insert into plp_mt_tab(a) values (3/0)" +PL/pgSQL function plpgsql_multistmt() line 5 at SQL statement +select * from plp_mt_tab; + a | b +---+--- +(0 rows) + +create or replace function plpgsql_multistmt() returns void as $$ +begin + insert into plp_mt_tab(a) values (3); + update plp_mt_tab set b = 1 where (a / 0) = 0; +end +$$ language plpgsql; +select plpgsql_multistmt(); +ERROR: division by zero +CONTEXT: SQL statement "update plp_mt_tab set b = 1 where (a / 0) = 0" +PL/pgSQL function plpgsql_multistmt() line 4 at SQL statement +select * from plp_mt_tab; + a | b +---+--- +(0 rows) + |