1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

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.
This commit is contained in:
Tom Lane 2007-02-13 19:39:48 +00:00
parent bc16005c0d
commit 538a983237

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.25 2006/10/06 17:13:58 petere Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.25.2.1 2007/02/13 19:39:48 tgl Exp $
* *
* NOTES * NOTES
* Each global transaction is associated with a global transaction * Each global transaction is associated with a global transaction
@ -392,6 +392,18 @@ LockGXact(const char *gid, Oid user)
errmsg("permission denied to finish prepared transaction"), errmsg("permission denied to finish prepared transaction"),
errhint("Must be superuser or the user that prepared the 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 */ /* OK for me to lock it */
gxact->locking_xid = GetTopTransactionId(); gxact->locking_xid = GetTopTransactionId();