]> granicus.if.org Git - postgresql/commit
Fix snapshot leak warning for some procedures
authorPeter Eisentraut <peter_e@gmx.net>
Thu, 23 Aug 2018 13:13:48 +0000 (15:13 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Mon, 27 Aug 2018 20:16:15 +0000 (22:16 +0200)
commit7a3b7bbfded3142aaa8edae2dbc88999568cc1cd
tree03984a905f939f36c31b94a66b5835b2b6e55942
parentcbdca00bef59ee204313fe8f0e4f36bc804a38aa
Fix snapshot leak warning for some procedures

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
9ee1cf04ab6bcefe03a11837b53f29ca9dc24c7a 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: Prabhat Sahu <prabhat.sahu@enterprisedb.com>
Reviewed-by: Jonathan S. Katz <jkatz@postgresql.org>
src/backend/utils/mmgr/portalmem.c
src/pl/plpgsql/src/expected/plpgsql_transaction.out
src/pl/plpgsql/src/sql/plpgsql_transaction.sql