Add regression test for two-phase transaction in postgres_fdw
authorMichael Paquier <[email protected]>
Wed, 13 Nov 2019 04:30:14 +0000 (13:30 +0900)
committerMichael Paquier <[email protected]>
Wed, 13 Nov 2019 04:30:14 +0000 (13:30 +0900)
postgres_fdw does not support two-phase transactions, so let's add a
small negative test case to check after it.  Note that this is checked
using an end-of-xact callback to ensure a proper connection cleanup with
the foreign server, which is called before checking if a server is able
to handle 2PC with max_prepared_xacts, so this test does not need an
alternate output file.

Author: Gilles Darold
Discussion: https://postgr.es/m/20191108090507[email protected]

contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/sql/postgres_fdw.sql

index f0c842a60789bd026bbfc68308c43911f491fbea..14180ee46983b94e9ab38613b0c7ed350e7aa755 100644 (file)
@@ -8781,3 +8781,16 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700
 
 -- Clean-up
 RESET enable_partitionwise_aggregate;
+-- Two-phase transactions are not supported.
+BEGIN;
+SELECT count(*) FROM ft1;
+ count 
+-------
+   822
+(1 row)
+
+-- error here
+PREPARE TRANSACTION 'fdw_tpc';
+ERROR:  cannot PREPARE a transaction that has operated on postgres_fdw foreign tables
+ROLLBACK;
+WARNING:  there is no transaction in progress
index 630b803e26276c582e360374b89226dbdce8f941..1c5c37b783ee29e1304b861641484e5c4b26eaed 100644 (file)
@@ -2479,3 +2479,10 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700
 
 -- Clean-up
 RESET enable_partitionwise_aggregate;
+
+-- Two-phase transactions are not supported.
+BEGIN;
+SELECT count(*) FROM ft1;
+-- error here
+PREPARE TRANSACTION 'fdw_tpc';
+ROLLBACK;