summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/plpgsql.out
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress/expected/plpgsql.out')
-rw-r--r--src/test/regress/expected/plpgsql.out43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index a22e2bfd0f1..8d20cd90482 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -3916,6 +3916,49 @@ SELECT * FROM leaker_1(true);
DROP FUNCTION leaker_1(bool);
DROP FUNCTION leaker_2(bool);
+-- Test for appropriate cleanup of non-simple expression evaluations
+-- (bug in all versions prior to August 2010)
+CREATE FUNCTION nonsimple_expr_test() RETURNS text[] AS $$
+DECLARE
+ arr text[];
+ lr text;
+ i integer;
+BEGIN
+ arr := array[array['foo','bar'], array['baz', 'quux']];
+ lr := 'fool';
+ i := 1;
+ -- use sub-SELECTs to make expressions non-simple
+ arr[(SELECT i)][(SELECT i+1)] := (SELECT lr);
+ RETURN arr;
+END;
+$$ LANGUAGE plpgsql;
+SELECT nonsimple_expr_test();
+ nonsimple_expr_test
+-------------------------
+ {{foo,fool},{baz,quux}}
+(1 row)
+
+DROP FUNCTION nonsimple_expr_test();
+CREATE FUNCTION nonsimple_expr_test() RETURNS integer AS $$
+declare
+ i integer NOT NULL := 0;
+begin
+ begin
+ i := (SELECT NULL::integer); -- should throw error
+ exception
+ WHEN OTHERS THEN
+ i := (SELECT 1::integer);
+ end;
+ return i;
+end;
+$$ LANGUAGE plpgsql;
+SELECT nonsimple_expr_test();
+ nonsimple_expr_test
+---------------------
+ 1
+(1 row)
+
+DROP FUNCTION nonsimple_expr_test();
-- Test handling of string literals.
set standard_conforming_strings = off;
create or replace function strtest() returns text as $$