summaryrefslogtreecommitdiff
path: root/src/test/regress/sql/plpgsql.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-11-16 18:10:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-11-16 18:10:16 +0000
commit7efa8411cc56383a9b7ac2203f310d0db81f0580 (patch)
treea205f416cfee9d6c54864d06c72a2aa6f686f9e6 /src/test/regress/sql/plpgsql.sql
parent2bb3bcfcf9edb57d7bd3635b2201688defee6676 (diff)
downloadpostgresql-7efa8411cc56383a9b7ac2203f310d0db81f0580.tar.gz
Rethink plpgsql's way of handling SPI execution during an exception block.
We don't really want to start a new SPI connection, just keep using the old one; otherwise we have memory management problems as illustrated by John Kennedy's bug report of today. This requires a bit of a hack to ensure the SPI stack state is properly restored, but then again what we were doing before was a hack too, strictly speaking. Add a regression test to cover this case.
Diffstat (limited to 'src/test/regress/sql/plpgsql.sql')
-rw-r--r--src/test/regress/sql/plpgsql.sql18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 367a73986e..f9f307b1ac 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -1696,6 +1696,24 @@ reset statement_timeout;
select * from foo;
+-- Test for pass-by-ref values being stored in proper context
+create function test_variable_storage() returns text as $$
+declare x text;
+begin
+ x := '1234';
+ begin
+ x := x || '5678';
+ -- force error inside subtransaction SPI context
+ perform trap_zero_divide(-100);
+ exception
+ when others then
+ x := x || '9012';
+ end;
+ return x;
+end$$ language plpgsql;
+
+select test_variable_storage();
+
--
-- test foreign key error trapping
--