• Peter Eisentraut's avatar
    Fix snapshot leak warning for some procedures · 7a3b7bbf
    Peter Eisentraut authored
    The problem arises with the combination of CALL with output parameters
    and doing a COMMIT inside the procedure.  When a CALL has output
    parameters, the portal uses the strategy PORTAL_UTIL_SELECT instead of
    PORTAL_MULTI_QUERY.  Using PORTAL_UTIL_SELECT causes the portal's
    snapshot to be registered with the current resource
    owner (portal->holdSnapshot); see
    9ee1cf04 for the reason.
    
    Normally, PortalDrop() unregisters the snapshot.  If not, then
    ResourceOwnerRelease() will print a warning about a snapshot leak on
    transaction commit.  A transaction commit normally drops all
    portals (PreCommit_Portals()), except the active portal.  So in case of
    the active portal, we need to manually release the snapshot to avoid the
    warning.
    Reported-by: default avatarPrabhat Sahu <prabhat.sahu@enterprisedb.com>
    Reviewed-by: default avatarJonathan S. Katz <jkatz@postgresql.org>
    7a3b7bbf
portalmem.c 35.1 KB