OSDN Git Service

Unify spelling of "canceled", "canceling", "cancellation"
[pg-rex/syncrep.git] / src / test / regress / expected / prepared_xacts.out
index 514a706..e094476 100644 (file)
@@ -9,7 +9,7 @@
 CREATE TABLE pxtest1 (foobar VARCHAR(10));
 INSERT INTO pxtest1 VALUES ('aaa');
 -- Test PREPARE TRANSACTION
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 UPDATE pxtest1 SET foobar = 'bbb' WHERE foobar = 'aaa';
 SELECT * FROM pxtest1;
  foobar 
@@ -45,7 +45,7 @@ SELECT gid FROM pg_prepared_xacts;
 (0 rows)
 
 -- Test COMMIT PREPARED
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 INSERT INTO pxtest1 VALUES ('ddd');
 SELECT * FROM pxtest1;
  foobar 
@@ -70,7 +70,7 @@ SELECT * FROM pxtest1;
 (2 rows)
 
 -- Test duplicate gids
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd';
 SELECT * FROM pxtest1;
  foobar 
@@ -86,19 +86,19 @@ SELECT gid FROM pg_prepared_xacts;
  foo3
 (1 row)
 
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 INSERT INTO pxtest1 VALUES ('fff');
+-- This should fail, because the gid foo3 is already in use
+PREPARE TRANSACTION 'foo3';
+ERROR:  transaction identifier "foo3" is already in use
 SELECT * FROM pxtest1;
  foobar 
 --------
  aaa
  ddd
- fff
-(3 rows)
+(2 rows)
 
--- This should fail, because the gid foo3 is already in use
-PREPARE TRANSACTION 'foo3';
-ERROR:  transaction identifier "foo3" is already in use
+ROLLBACK PREPARED 'foo3';
 SELECT * FROM pxtest1;
  foobar 
 --------
@@ -106,7 +106,24 @@ SELECT * FROM pxtest1;
  ddd
 (2 rows)
 
-ROLLBACK PREPARED 'foo3';
+-- Test serialization failure (SSI)
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd';
+SELECT * FROM pxtest1;
+ foobar 
+--------
+ aaa
+ eee
+(2 rows)
+
+PREPARE TRANSACTION 'foo4';
+SELECT gid FROM pg_prepared_xacts;
+ gid  
+------
+ foo4
+(1 row)
+
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 SELECT * FROM pxtest1;
  foobar 
 --------
@@ -114,10 +131,28 @@ SELECT * FROM pxtest1;
  ddd
 (2 rows)
 
+INSERT INTO pxtest1 VALUES ('fff');
+-- This should fail, because the two transactions have a write-skew anomaly
+PREPARE TRANSACTION 'foo5';
+ERROR:  could not serialize access due to read/write dependencies among transactions
+DETAIL:  Canceled on commit attempt with conflict in from prepared pivot.
+HINT:  The transaction might succeed if retried.
+SELECT gid FROM pg_prepared_xacts;
+ gid  
+------
+ foo4
+(1 row)
+
+ROLLBACK PREPARED 'foo4';
+SELECT gid FROM pg_prepared_xacts;
+ gid 
+-----
+(0 rows)
+
 -- Clean up
 DROP TABLE pxtest1;
 -- Test subtransactions
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
   CREATE TABLE pxtest2 (a int);
   INSERT INTO pxtest2 VALUES (1);
   SAVEPOINT a;
@@ -128,7 +163,7 @@ BEGIN;
 PREPARE TRANSACTION 'regress-one';
 CREATE TABLE pxtest3(fff int);
 -- Test shared invalidation
-BEGIN;
+BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
   DROP TABLE pxtest3;
   CREATE TABLE pxtest4 (a int);
   INSERT INTO pxtest4 VALUES (1);
@@ -148,6 +183,8 @@ ERROR:  cursor "foo" does not exist
 -- Table doesn't exist, the creation hasn't been committed yet
 SELECT * FROM pxtest2;
 ERROR:  relation "pxtest2" does not exist
+LINE 1: SELECT * FROM pxtest2;
+                      ^
 -- There should be two prepared transactions
 SELECT gid FROM pg_prepared_xacts;
      gid     
@@ -157,7 +194,7 @@ SELECT gid FROM pg_prepared_xacts;
 (2 rows)
 
 -- pxtest3 should be locked because of the pending DROP
-set statement_timeout to 1000;
+set statement_timeout to 2000;
 SELECT * FROM pxtest3;
 ERROR:  canceling statement due to statement timeout
 reset statement_timeout;
@@ -172,7 +209,7 @@ SELECT gid FROM pg_prepared_xacts;
 (2 rows)
 
 -- pxtest3 should still be locked because of the pending DROP
-set statement_timeout to 1000;
+set statement_timeout to 2000;
 SELECT * FROM pxtest3;
 ERROR:  canceling statement due to statement timeout
 reset statement_timeout;
@@ -202,6 +239,8 @@ SELECT gid FROM pg_prepared_xacts;
 COMMIT PREPARED 'regress-two';
 SELECT * FROM pxtest3;
 ERROR:  relation "pxtest3" does not exist
+LINE 1: SELECT * FROM pxtest3;
+                      ^
 -- There should be no prepared transactions
 SELECT gid FROM pg_prepared_xacts;
  gid 
@@ -210,4 +249,6 @@ SELECT gid FROM pg_prepared_xacts;
 
 -- Clean up
 DROP TABLE pxtest2;
+DROP TABLE pxtest3;  -- will still be there if prepared xacts are disabled
+ERROR:  table "pxtest3" does not exist
 DROP TABLE pxtest4;