Free queryDesc while dropping a portal.
authorPavan Deolasee <[email protected]>
Tue, 18 Aug 2015 11:36:23 +0000 (17:06 +0530)
committerPavan Deolasee <[email protected]>
Tue, 18 Aug 2015 11:36:23 +0000 (17:06 +0530)
Once we decide that the portal is no longer an active producing portal, we
decide to release all resources. But before that we must free the queryDesc and
unregister any snapshots to avoid snapshot-leak warnings later on

src/backend/utils/mmgr/portalmem.c

index b1e1dc935eda8f19e9947a940daebb91eb3b0bff..2880b2c7287173c3c91fe1c3547acf2c389c7d81 100644 (file)
@@ -584,6 +584,15 @@ PortalDrop(Portal portal, bool isTopCommit)
         */
        if (portalIsProducing(portal))
                return;
+
+       if (portal->queryDesc)
+       {
+               ResourceOwner saveResourceOwner = CurrentResourceOwner;
+               CurrentResourceOwner = portal->resowner;
+               FreeQueryDesc(portal->queryDesc);
+               CurrentResourceOwner = saveResourceOwner;
+               portal->queryDesc = NULL;
+       }
 #endif
 
        /*