mirror of
https://github.com/postgres/postgres.git
synced 2025-12-01 12:18:01 +03:00
Two-phase commit. Original patch by Heikki Linnakangas, with additional
hacking by Alvaro Herrera and Tom Lane.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.80 2005/05/29 04:23:06 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.81 2005/06/17 22:32:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -466,6 +466,48 @@ CommitHoldablePortals(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pre-prepare processing for portals.
|
||||
*
|
||||
* Currently we refuse PREPARE if the transaction created any holdable
|
||||
* cursors, since it's quite unclear what to do with one. However, this
|
||||
* has the same API as CommitHoldablePortals and is invoked in the same
|
||||
* way by xact.c, so that we can easily do something reasonable if anyone
|
||||
* comes up with something reasonable to do.
|
||||
*
|
||||
* Returns TRUE if any holdable cursors were processed, FALSE if not.
|
||||
*/
|
||||
bool
|
||||
PrepareHoldablePortals(void)
|
||||
{
|
||||
bool result = false;
|
||||
HASH_SEQ_STATUS status;
|
||||
PortalHashEnt *hentry;
|
||||
|
||||
hash_seq_init(&status, PortalHashTable);
|
||||
|
||||
while ((hentry = (PortalHashEnt *) hash_seq_search(&status)) != NULL)
|
||||
{
|
||||
Portal portal = hentry->portal;
|
||||
|
||||
/* Is it a holdable portal created in the current xact? */
|
||||
if ((portal->cursorOptions & CURSOR_OPT_HOLD) &&
|
||||
portal->createSubid != InvalidSubTransactionId &&
|
||||
portal->status == PORTAL_READY)
|
||||
{
|
||||
/*
|
||||
* We are exiting the transaction that created a holdable
|
||||
* cursor. Can't do PREPARE.
|
||||
*/
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot PREPARE a transaction that has created a cursor WITH HOLD")));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pre-commit processing for portals.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user