foo1
(1 row)
+-- Test pgxc_prepared_xacts system view
+SELECT pgxc_prepared_xact FROM pgxc_prepared_xacts ORDER by 1;
+ pgxc_prepared_xact
+--------------------
+ foo1
+(1 row)
+
-- Test ROLLBACK PREPARED
ROLLBACK PREPARED 'foo1';
SELECT * FROM pxtest1 ORDER BY foobar;
aaa
(1 row)
+-- Check prepared transactions on Coordinator
SELECT gid FROM pg_prepared_xacts ORDER BY gid;
gid
-----
(0 rows)
+-- Check prepared transactions in the cluster
+SELECT pgxc_prepared_xact FROM pgxc_prepared_xacts ORDER by 1;
+ pgxc_prepared_xact
+--------------------
+(0 rows)
+
-- Test COMMIT PREPARED
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
INSERT INTO pxtest1 VALUES ('ddd');
(2 rows)
PREPARE TRANSACTION 'foo3';
+-- Check prepared transactions on Coordinator
SELECT gid FROM pg_prepared_xacts ORDER BY gid;
gid
------
foo3
(1 row)
+-- Check prepared transactions in the cluster
+SELECT pgxc_prepared_xact FROM pgxc_prepared_xacts ORDER by 1;
+ pgxc_prepared_xact
+--------------------
+ foo3
+(1 row)
+
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
INSERT INTO pxtest1 VALUES ('fff');
SELECT * FROM pxtest1 ORDER BY foobar;
-- 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;
+SELECT * FROM pxtest1 ORDER BY foobar;
foobar
--------
aaa
(2 rows)
ROLLBACK PREPARED 'foo3';
-SELECT * FROM pxtest1;
+SELECT * FROM pxtest1 ORDER BY foobar;
foobar
--------
aaa
regress-two
(1 row)
+-- Check prepared transactions in the cluster
+SELECT pgxc_prepared_xact FROM pgxc_prepared_xacts ORDER by 1;
+ pgxc_prepared_xact
+--------------------
+ regress-two
+(1 row)
+
-- Commit table drop
COMMIT PREPARED 'regress-two';
SELECT * FROM pxtest3;
-----
(0 rows)
+-- Check prepared transactions in the cluster
+SELECT pgxc_prepared_xact FROM pgxc_prepared_xacts ORDER by 1;
+ pgxc_prepared_xact
+--------------------
+(0 rows)
+
-- Clean up
DROP TABLE pxtest2;
DROP TABLE pxtest3; -- will still be there if prepared xacts are disabled