diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/portalcmds.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 8246b25774e..39b73c7a609 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.44 2005/11/03 17:11:35 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.44.2.1 2007/02/06 22:49:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -385,15 +385,30 @@ PersistHoldablePortal(Portal portal) ExecutorEnd(queryDesc); /* - * Reset the position in the result set: ideally, this could be + * Set the position in the result set: ideally, this could be * implemented by just skipping straight to the tuple # that we need * to be at, but the tuplestore API doesn't support that. So we start * at the beginning of the tuplestore and iterate through it until we - * reach where we need to be. FIXME someday? + * reach where we need to be. FIXME someday? (Fortunately, the + * typical case is that we're supposed to be at or near the start + * of the result set, so this isn't as bad as it sounds.) */ MemoryContextSwitchTo(portal->holdContext); - if (!portal->atEnd) + if (portal->atEnd) + { + /* we can handle this case even if posOverflow */ + HeapTuple tup; + bool should_free; + + while ((tup = tuplestore_gettuple(portal->holdStore, true, + &should_free)) != NULL) + { + if (should_free) + pfree(tup); + } + } + else { long store_pos; |