postgres.git / summary / log / commit / refs
commit e6aa62ec1428c33a9c997cf06351653c8ceea8d5
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue Feb 13 19:39:55 2007 +0000
First released in: 8.3.0, 8.1.9, 8.2.4
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.
src/backend/access/transam/twophase.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index ca44e19a8ef..193fc2b6fbb 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.16.2.1 2005/11/22 18:23:05 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.16.2.2 2007/02/13 19:39:55 tgl Exp $
*
* NOTES
* Each global transaction is associated with a global transaction
@@ -390,6 +390,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();
[parent: 3e5a4a9a088d]