diff -U3 /tmp/cirrus-ci-build/src/pl/plpgsql/src/expected/plpgsql_transaction.out /tmp/cirrus-ci-build/build-32/testrun/plpgsql/regress/results/plpgsql_transaction.out --- /tmp/cirrus-ci-build/src/pl/plpgsql/src/expected/plpgsql_transaction.out 2024-03-19 00:05:01.328100399 +0000 +++ /tmp/cirrus-ci-build/build-32/testrun/plpgsql/regress/results/plpgsql_transaction.out 2024-03-19 00:11:39.855818334 +0000 @@ -513,229 +513,7 @@ INSERT INTO test3 (y) VALUES (3); -- won't get here END; $$; -ERROR: duplicate key value violates unique constraint "test3_y_key" -DETAIL: Key (y)=(1) already exists. -CONTEXT: PL/pgSQL function inline_code_block line 9 at COMMIT -SELECT * FROM test3; - y ---- - 1 -(1 row) - --- failure while trying to persist a cursor across a transaction (bug #15703) -CREATE PROCEDURE cursor_fail_during_commit() - LANGUAGE plpgsql -AS $$ - DECLARE id int; - BEGIN - FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP - INSERT INTO test1 VALUES(id); - COMMIT; - END LOOP; - END; -$$; -TRUNCATE test1; -CALL cursor_fail_during_commit(); -ERROR: division by zero -CONTEXT: PL/pgSQL function cursor_fail_during_commit() line 6 at COMMIT --- note that error occurs during first COMMIT, hence nothing is in test1 -SELECT count(*) FROM test1; - count -------- - 0 -(1 row) - -CREATE PROCEDURE cursor_fail_during_rollback() - LANGUAGE plpgsql -AS $$ - DECLARE id int; - BEGIN - FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP - INSERT INTO test1 VALUES(id); - ROLLBACK; - END LOOP; - END; -$$; -TRUNCATE test1; -CALL cursor_fail_during_rollback(); -ERROR: division by zero -CONTEXT: PL/pgSQL function cursor_fail_during_rollback() line 6 at ROLLBACK -SELECT count(*) FROM test1; - count -------- - 0 -(1 row) - --- SET TRANSACTION -DO LANGUAGE plpgsql $$ -BEGIN - PERFORM 1; - RAISE INFO '%', current_setting('transaction_isolation'); - COMMIT; - SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; - PERFORM 1; - RAISE INFO '%', current_setting('transaction_isolation'); - COMMIT; - SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; - PERFORM 1; - RAISE INFO '%', current_setting('transaction_isolation'); - COMMIT; -END; -$$; -INFO: read committed -INFO: repeatable read -INFO: serializable --- error cases -DO LANGUAGE plpgsql $$ -BEGIN - SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; -END; -$$; -ERROR: SET TRANSACTION ISOLATION LEVEL must be called before any query -CONTEXT: SQL statement "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ" -PL/pgSQL function inline_code_block line 3 at SQL statement -DO LANGUAGE plpgsql $$ -BEGIN - SAVEPOINT foo; -END; -$$; -ERROR: unsupported transaction command in PL/pgSQL -CONTEXT: PL/pgSQL function inline_code_block line 3 at SQL statement -DO LANGUAGE plpgsql $$ -BEGIN - EXECUTE 'COMMIT'; -END; -$$; -ERROR: EXECUTE of transaction commands is not implemented -CONTEXT: PL/pgSQL function inline_code_block line 3 at EXECUTE --- snapshot handling test -TRUNCATE test2; -CREATE PROCEDURE transaction_test9() -LANGUAGE SQL -AS $$ -INSERT INTO test2 VALUES (42); -$$; -DO LANGUAGE plpgsql $$ -BEGIN - ROLLBACK; - CALL transaction_test9(); -END -$$; -SELECT * FROM test2; - x ----- - 42 -(1 row) - --- another snapshot handling case: argument expressions of a CALL need --- to be evaluated with an up-to-date snapshot -CREATE FUNCTION report_count() RETURNS int -STABLE LANGUAGE sql -AS $$ SELECT COUNT(*) FROM test2 $$; -CREATE PROCEDURE transaction_test9b(cnt int) -LANGUAGE plpgsql -AS $$ -BEGIN - RAISE NOTICE 'count = %', cnt; -END -$$; -DO $$ -BEGIN - CALL transaction_test9b(report_count()); - INSERT INTO test2 VALUES(43); - CALL transaction_test9b(report_count()); -END -$$; -NOTICE: count = 1 -NOTICE: count = 2 --- Test transaction in procedure with output parameters. This uses a --- different portal strategy and different code paths in pquery.c. -CREATE PROCEDURE transaction_test10a(INOUT x int) -LANGUAGE plpgsql -AS $$ -BEGIN - x := x + 1; - COMMIT; -END; -$$; -CALL transaction_test10a(10); - x ----- - 11 -(1 row) - -CREATE PROCEDURE transaction_test10b(INOUT x int) -LANGUAGE plpgsql -AS $$ -BEGIN - x := x - 1; - ROLLBACK; -END; -$$; -CALL transaction_test10b(10); - x ---- - 9 -(1 row) - --- transaction timestamp vs. statement timestamp -CREATE PROCEDURE transaction_test11() -LANGUAGE plpgsql -AS $$ -DECLARE - s1 timestamp with time zone; - s2 timestamp with time zone; - s3 timestamp with time zone; - t1 timestamp with time zone; - t2 timestamp with time zone; - t3 timestamp with time zone; -BEGIN - s1 := statement_timestamp(); - t1 := transaction_timestamp(); - ASSERT s1 = t1; - PERFORM pg_sleep(0.001); - COMMIT; - s2 := statement_timestamp(); - t2 := transaction_timestamp(); - ASSERT s2 = s1; - ASSERT t2 > t1; - PERFORM pg_sleep(0.001); - ROLLBACK; - s3 := statement_timestamp(); - t3 := transaction_timestamp(); - ASSERT s3 = s1; - ASSERT t3 > t2; -END; -$$; -CALL transaction_test11(); --- transaction chain -TRUNCATE test1; -DO LANGUAGE plpgsql $$ -BEGIN - ROLLBACK; - SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; - FOR i IN 0..3 LOOP - RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); - INSERT INTO test1 (a) VALUES (i); - IF i % 2 = 0 THEN - COMMIT AND CHAIN; - ELSE - ROLLBACK AND CHAIN; - END IF; - END LOOP; -END -$$; -INFO: transaction_isolation = repeatable read -INFO: transaction_isolation = repeatable read -INFO: transaction_isolation = repeatable read -INFO: transaction_isolation = repeatable read -SELECT * FROM test1; - a | b ----+--- - 0 | - 2 | -(2 rows) - -DROP TABLE test1; -DROP TABLE test2; -DROP TABLE test3; +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. +connection to server was lost diff -U3 /tmp/cirrus-ci-build/src/pl/plpgsql/src/expected/plpgsql_trap.out /tmp/cirrus-ci-build/build-32/testrun/plpgsql/regress/results/plpgsql_trap.out --- /tmp/cirrus-ci-build/src/pl/plpgsql/src/expected/plpgsql_trap.out 2024-03-19 00:05:01.328100399 +0000 +++ /tmp/cirrus-ci-build/build-32/testrun/plpgsql/regress/results/plpgsql_trap.out 2024-03-19 00:11:41.103817047 +0000 @@ -190,66 +190,7 @@ create temp table leaf(f1 int references root deferrable); insert into root values(1); insert into leaf values(1); -insert into leaf values(2); -- fails -ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "root". -create function trap_foreign_key(int) returns int as $$ -begin - begin -- start a subtransaction - insert into leaf values($1); - exception - when foreign_key_violation then - raise notice 'caught foreign_key_violation'; - return 0; - end; - return 1; -end$$ language plpgsql; -create function trap_foreign_key_2() returns int as $$ -begin - begin -- start a subtransaction - set constraints all immediate; - exception - when foreign_key_violation then - raise notice 'caught foreign_key_violation'; - return 0; - end; - return 1; -end$$ language plpgsql; -select trap_foreign_key(1); - trap_foreign_key ------------------- - 1 -(1 row) - -select trap_foreign_key(2); -- detects FK violation -NOTICE: caught foreign_key_violation - trap_foreign_key ------------------- - 0 -(1 row) - -begin; - set constraints all deferred; - select trap_foreign_key(2); -- should not detect FK violation - trap_foreign_key ------------------- - 1 -(1 row) - - savepoint x; - set constraints all immediate; -- fails -ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "root". - rollback to x; - select trap_foreign_key_2(); -- detects FK violation -NOTICE: caught foreign_key_violation - trap_foreign_key_2 --------------------- - 0 -(1 row) - -commit; -- still fails -ERROR: insert or update on table "leaf" violates foreign key constraint "leaf_f1_fkey" -DETAIL: Key (f1)=(2) is not present in table "root". -drop function trap_foreign_key(int); -drop function trap_foreign_key_2(); +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. +connection to server was lost