summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-04-11 15:59:34 +0000
committerTom Lane2005-04-11 15:59:34 +0000
commit0c400f1bbc3231ed75e11d3ab0ec7a4a9d3c8486 (patch)
tree75cefe74e642de978d9d11efc35b63d2962afb16
parent72fd5590375fdb671569a6d59157ad758bd5cb8e (diff)
PersistHoldablePortal must establish the correct value for ActiveSnapshot
while completing execution of the cursor's query. Otherwise we get wrong answers or even crashes from non-volatile functions called by the query. Per report from andrew@supernews.
-rw-r--r--src/backend/commands/portalcmds.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c
index 3d5133f8254..b3170499adc 100644
--- a/src/backend/commands/portalcmds.c
+++ b/src/backend/commands/portalcmds.c
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.39 2005/03/25 21:57:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.40 2005/04/11 15:59:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -309,6 +309,7 @@ PersistHoldablePortal(Portal portal)
{
QueryDesc *queryDesc = PortalGetQueryDesc(portal);
Portal saveActivePortal;
+ Snapshot saveActiveSnapshot;
ResourceOwner saveResourceOwner;
MemoryContext savePortalContext;
MemoryContext saveQueryContext;
@@ -350,12 +351,14 @@ PersistHoldablePortal(Portal portal)
* Set up global portal context pointers.
*/
saveActivePortal = ActivePortal;
+ saveActiveSnapshot = ActiveSnapshot;
saveResourceOwner = CurrentResourceOwner;
savePortalContext = PortalContext;
saveQueryContext = QueryContext;
PG_TRY();
{
ActivePortal = portal;
+ ActiveSnapshot = queryDesc->snapshot;
CurrentResourceOwner = portal->resowner;
PortalContext = PortalGetHeapMemory(portal);
QueryContext = portal->queryContext;
@@ -428,6 +431,7 @@ PersistHoldablePortal(Portal portal)
/* Restore global vars and propagate error */
ActivePortal = saveActivePortal;
+ ActiveSnapshot = saveActiveSnapshot;
CurrentResourceOwner = saveResourceOwner;
PortalContext = savePortalContext;
QueryContext = saveQueryContext;
@@ -442,6 +446,7 @@ PersistHoldablePortal(Portal portal)
portal->status = PORTAL_READY;
ActivePortal = saveActivePortal;
+ ActiveSnapshot = saveActiveSnapshot;
CurrentResourceOwner = saveResourceOwner;
PortalContext = savePortalContext;
QueryContext = saveQueryContext;