Skip to content

Commit 94fec48

Browse files
committed
Add regression test for two-phase transaction in postgres_fdw
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.GC1768@paquier.xyz
1 parent 1379fd5 commit 94fec48

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8781,3 +8781,16 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700
87818781

87828782
-- Clean-up
87838783
RESET enable_partitionwise_aggregate;
8784+
-- Two-phase transactions are not supported.
8785+
BEGIN;
8786+
SELECT count(*) FROM ft1;
8787+
count
8788+
-------
8789+
822
8790+
(1 row)
8791+
8792+
-- error here
8793+
PREPARE TRANSACTION 'fdw_tpc';
8794+
ERROR: cannot PREPARE a transaction that has operated on postgres_fdw foreign tables
8795+
ROLLBACK;
8796+
WARNING: there is no transaction in progress

contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,3 +2479,10 @@ SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b HAVING sum(a) < 700
24792479

24802480
-- Clean-up
24812481
RESET enable_partitionwise_aggregate;
2482+
2483+
-- Two-phase transactions are not supported.
2484+
BEGIN;
2485+
SELECT count(*) FROM ft1;
2486+
-- error here
2487+
PREPARE TRANSACTION 'fdw_tpc';
2488+
ROLLBACK;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy