Skip to content

Commit 0c7a28a

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Fix error message for PREPARE TRANSACTION.
Currently, postgres_fdw does not support preparing a remote transaction for two-phase commit even in the case where the remote transaction is read-only, but the old error message appeared to imply that that was not supported only if the remote transaction modified remote tables. Change the message so as to include the case where the remote transaction is read-only. Also fix a comment above the message. Also add a note about the lack of supporting PREPARE TRANSACTION to the postgres_fdw documentation. Reported-by: Gilles Darold Author: Gilles Darold and Etsuro Fujita Reviewed-by: Michael Paquier and Kyotaro Horiguchi Backpatch-through: 9.4 Discussion: https://postgr.es/m/08600ed3-3084-be70-65ba-279ab19618a5%40darold.net
1 parent 5292570 commit 0c7a28a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

contrib/postgres_fdw/connection.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,17 @@ pgfdw_xact_callback(XactEvent event, void *arg)
719719
case XACT_EVENT_PRE_PREPARE:
720720

721721
/*
722-
* We disallow remote transactions that modified anything,
723-
* since it's not very reasonable to hold them open until
724-
* the prepared transaction is committed. For the moment,
725-
* throw error unconditionally; later we might allow
726-
* read-only cases. Note that the error will cause us to
727-
* come right back here with event == XACT_EVENT_ABORT, so
728-
* we'll clean up the connection state at that point.
722+
* We disallow any remote transactions, since it's not
723+
* very reasonable to hold them open until the prepared
724+
* transaction is committed. For the moment, throw error
725+
* unconditionally; later we might allow read-only cases.
726+
* Note that the error will cause us to come right back
727+
* here with event == XACT_EVENT_ABORT, so we'll clean up
728+
* the connection state at that point.
729729
*/
730730
ereport(ERROR,
731731
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
732-
errmsg("cannot prepare a transaction that modified remote tables")));
732+
errmsg("cannot PREPARE a transaction that has operated on postgres_fdw foreign tables")));
733733
break;
734734
case XACT_EVENT_PARALLEL_COMMIT:
735735
case XACT_EVENT_COMMIT:

doc/src/sgml/postgres-fdw.sgml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@
478478
COMMITTED</> local transaction. A future
479479
<productname>PostgreSQL</productname> release might modify these rules.
480480
</para>
481+
482+
<para>
483+
Note that it is currently not supported by
484+
<filename>postgres_fdw</filename> to prepare the remote transaction for
485+
two-phase commit.
486+
</para>
481487
</sect2>
482488

483489
<sect2>

0 commit comments

Comments
 (0)