Fix transaction.sql tests in higher isolation levels.

It seems like a useful sanity check to be able to run "installcheck"
against a cluster running with default_transaction_level set to
serializable or repeatable read.  Only one thing currently fails in
those configurations, so let's fix that.

No back-patch for now, because it fails in many other places in some of
the stable branches.  We'd have to go back and fix those too if we
included this configuration in automated testing.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGJUaHeK%3DHLATxF1JOKDjKJVrBKA-zmbPAebOM0Se2FQRg%40mail.gmail.com
This commit is contained in:
Thomas Munro 2021-03-17 17:13:43 +13:00
parent 6b67d72b60
commit 3792959949
2 changed files with 6 additions and 0 deletions

View File

@ -1026,6 +1026,7 @@ SHOW transaction_isolation; -- transaction is active at this point
(1 row)
ROLLBACK;
SET default_transaction_isolation = 'read committed';
-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
@ -1043,6 +1044,7 @@ SHOW transaction_isolation; -- out of transaction block
read committed
(1 row)
RESET default_transaction_isolation;
SELECT * FROM abc ORDER BY 1;
a
----

View File

@ -578,6 +578,8 @@ START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (16)\
SHOW transaction_isolation; -- transaction is active at this point
ROLLBACK;
SET default_transaction_isolation = 'read committed';
-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error
SHOW transaction_isolation; -- out of transaction block
@ -585,6 +587,8 @@ SHOW transaction_isolation; -- out of transaction block
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (19)\; ROLLBACK\; INSERT INTO abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error
SHOW transaction_isolation; -- out of transaction block
RESET default_transaction_isolation;
SELECT * FROM abc ORDER BY 1;
DROP TABLE abc;