summaryrefslogtreecommitdiff
path: root/src/backend/commands/portalcmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/portalcmds.c')
-rw-r--r--src/backend/commands/portalcmds.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c
index dda592c03a..60aca3ce8e 100644
--- a/src/backend/commands/portalcmds.c
+++ b/src/backend/commands/portalcmds.c
@@ -254,7 +254,14 @@ PortalCleanup(Portal portal)
queryDesc = PortalGetQueryDesc(portal);
if (queryDesc)
{
+ /*
+ * Reset the queryDesc before anything else. This prevents us
+ * from trying to shut down the executor twice, in case of an
+ * error below. The transaction abort mechanisms will take care
+ * of resource cleanup in such a case.
+ */
portal->queryDesc = NULL;
+
if (portal->status != PORTAL_FAILED)
{
ResourceOwner saveResourceOwner;
@@ -264,7 +271,7 @@ PortalCleanup(Portal portal)
PG_TRY();
{
CurrentResourceOwner = portal->resowner;
- /* we do not need AfterTriggerEndQuery() here */
+ ExecutorFinish(queryDesc);
ExecutorEnd(queryDesc);
FreeQueryDesc(queryDesc);
}
@@ -371,7 +378,7 @@ PersistHoldablePortal(Portal portal)
* Now shut down the inner executor.
*/
portal->queryDesc = NULL; /* prevent double shutdown */
- /* we do not need AfterTriggerEndQuery() here */
+ ExecutorFinish(queryDesc);
ExecutorEnd(queryDesc);
FreeQueryDesc(queryDesc);