Hi,
As per the following code, t1 is a remote table through postgres_fdw:
test=# BEGIN;
BEGIN
test=# SELECT * FROM t1;
...
test=# PREPARE TRANSACTION 'gxid1';
ERROR: cannot prepare a transaction that modified remote tables
I have attached a patch to the documentation that adds remote tables to
the list of objects where any operation prevent using a prepared
transaction, currently it is just notified "operations involving
temporary tables or the session's temporary namespace".
The second patch modify the message returned by postgres_fdw as per the
SELECT statement above the message should be more comprehensible with:
ERROR: cannot PREPARE a transaction that has operated on remote tables
like for temporary objects:
ERROR: cannot PREPARE a transaction that has operated on temporary
objects
Best regards,
--
Gilles
--
Gilles Darold
http://www.darold.net/
diff --git a/doc/src/sgml/ref/prepare_transaction.sgml b/doc/src/sgml/ref/prepare_transaction.sgml
index 5016ca287e..443caf131e 100644
--- a/doc/src/sgml/ref/prepare_transaction.sgml
+++ b/doc/src/sgml/ref/prepare_transaction.sgml
@@ -99,8 +99,8 @@ PREPARE TRANSACTION <replaceable class="parameter">transaction_id</replaceable>
<para>
It is not currently allowed to <command>PREPARE</command> a transaction that
has executed any operations involving temporary tables or the session's
- temporary namespace, created any cursors <literal>WITH HOLD</literal>, or
- executed <command>LISTEN</command>, <command>UNLISTEN</command>, or
+ temporary namespace or remote tables, created any cursors <literal>WITH HOLD</literal>,
+ or executed <command>LISTEN</command>, <command>UNLISTEN</command>, or
<command>NOTIFY</command>.
Those features are too tightly
tied to the current session to be useful in a transaction to be prepared.
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 7cd69cc709..2f5c37b159 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -725,7 +725,7 @@ pgfdw_xact_callback(XactEvent event, void *arg)
*/
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot prepare a transaction that modified remote tables")));
+ errmsg("cannot prepare a transaction that has operated on remote tables")));
break;
case XACT_EVENT_PARALLEL_COMMIT:
case XACT_EVENT_COMMIT: