OSDN Git Service

Unify spelling of "canceled", "canceling", "cancellation"
[pg-rex/syncrep.git] / src / test / regress / expected / prepared_xacts.out
index 1a6b4ce..e094476 100644 (file)
@@ -88,17 +88,17 @@ SELECT gid FROM pg_prepared_xacts;
 
 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,6 +131,24 @@ 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