diff options
Diffstat (limited to 'src/backend/utils/mmgr/portalmem.c')
-rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 26c5dd02a31..b55a3430256 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -467,6 +467,48 @@ CommitHoldablePortals(void) } /* + * 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. * * Remove all non-holdable portals created in this transaction. |