aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-13 19:39:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-13 19:39:42 +0000
commitcaf2b64a7574133a253a657591cde51cbc15e576 (patch)
tree3aa2acde6c67a0772e9db13977680800cecafb3b /src
parentcf4cc7843c17db5142a12edddb1bd17b33ea72d8 (diff)
downloadpostgresql-caf2b64a7574133a253a657591cde51cbc15e576.tar.gz
postgresql-caf2b64a7574133a253a657591cde51cbc15e576.zip
Disallow committing a prepared transaction unless we are in the same database
it was executed in. Someday it might be nice to allow cross-DB commits, but work would be needed in NOTIFY and perhaps other places. Per Heikki.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/twophase.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 45220d11964..55f6b88bcd0 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.27 2007/01/16 13:28:56 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.28 2007/02/13 19:39:42 tgl Exp $
*
* NOTES
* Each global transaction is associated with a global transaction
@@ -393,6 +393,18 @@ LockGXact(const char *gid, Oid user)
errmsg("permission denied to finish prepared transaction"),
errhint("Must be superuser or the user that prepared the transaction.")));
+ /*
+ * Note: it probably would be possible to allow committing from another
+ * database; but at the moment NOTIFY is known not to work and there
+ * may be some other issues as well. Hence disallow until someone
+ * gets motivated to make it work.
+ */
+ if (MyDatabaseId != gxact->proc.databaseId)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("prepared transaction belongs to another database"),
+ errhint("Connect to the database where the transaction was prepared to finish it.")));
+
/* OK for me to lock it */
gxact->locking_xid = GetTopTransactionId();