Fix transaction.sql tests in higher isolation levels.
authorThomas Munro
Wed, 17 Mar 2021 04:13:43 +0000 (17:13 +1300)
committerThomas Munro
Wed, 17 Mar 2021 04:26:20 +0000 (17:26 +1300)
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
Discussion: https://postgr.es/m/CA%2BhUKGJUaHeK%3DHLATxF1JOKDjKJVrBKA-zmbPAebOM0Se2FQRg%40mail.gmail.com

src/test/regress/expected/transactions.out
src/test/regress/sql/transactions.sql

index 75dc6558d82ec5e29c6560e157a5d41d844e805e..61862d595d1abec90127bb56a4ff17f2581c750c 100644 (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  
 ----
index d1b6ed0280d65aed5ab36af89c746d523310c761..8886280c0a628faa1afff0a95cc7920f5eea8911 100644 (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;