Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit caf2b64

Browse files
committed
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.
1 parent cf4cc78 commit caf2b64

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/access/transam/twophase.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.27 2007/01/16 13:28:56 alvherre Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.28 2007/02/13 19:39:42 tgl Exp $
1111
*
1212
* NOTES
1313
* Each global transaction is associated with a global transaction
@@ -393,6 +393,18 @@ LockGXact(const char *gid, Oid user)
393393
errmsg("permission denied to finish prepared transaction"),
394394
errhint("Must be superuser or the user that prepared the transaction.")));
395395

396+
/*
397+
* Note: it probably would be possible to allow committing from another
398+
* database; but at the moment NOTIFY is known not to work and there
399+
* may be some other issues as well. Hence disallow until someone
400+
* gets motivated to make it work.
401+
*/
402+
if (MyDatabaseId != gxact->proc.databaseId)
403+
ereport(ERROR,
404+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
405+
errmsg("prepared transaction belongs to another database"),
406+
errhint("Connect to the database where the transaction was prepared to finish it.")));
407+
396408
/* OK for me to lock it */
397409
gxact->locking_xid = GetTopTransactionId();
398410

0 commit comments

Comments
 (0)