From d4631ee77a72c409de1be5f524354d372bcf66fb Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 13 Feb 2007 19:39:55 +0000 Subject: [PATCH] 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 636216f40a..fe1eadd33e 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -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(); -- 2.39.5