aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/xact.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index f665e38ecfc..18467d96d28 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2279,6 +2279,18 @@ PrepareTransaction(void)
errmsg("cannot PREPARE a transaction that has operated on temporary tables")));
/*
+ * Similarly, PREPARE TRANSACTION is not allowed if the temporary
+ * namespace has been involved in this transaction as we cannot allow it
+ * to create, lock, or even drop objects within the temporary namespace
+ * as this can mess up with this session or even a follow-up session
+ * trying to use the same temporary namespace.
+ */
+ if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot PREPARE a transaction that has operated on temporary namespace")));
+
+ /*
* Likewise, don't allow PREPARE after pg_export_snapshot. This could be
* supported if we added cleanup logic to twophase.c, but for now it
* doesn't seem worth the trouble.