]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix several memory leaks when rescanning SRFs. Arrange for an SRF's
authorNeil Conway <neilc@samurai.com>
Fri, 29 Feb 2008 02:49:47 +0000 (02:49 +0000)
committerNeil Conway <neilc@samurai.com>
Fri, 29 Feb 2008 02:49:47 +0000 (02:49 +0000)
commit5694053570da490c0fa3a8f9245bce3c652215c5
treeecc6f999e0df2d24fff3f7debe2df4bcf1c53b4b
parentc05c8fe5d7e260aabcb54ced95dbb0cb79a4283f
Fix several memory leaks when rescanning SRFs. Arrange for an SRF's
"multi_call_ctx" to be a distinct sub-context of the EState's per-query
context, and delete the multi_call_ctx as soon as the SRF finishes
execution. This avoids leaking SRF memory until the end of the current
query, which is particularly egregious when the SRF is scanned
multiple times. This change also fixes a leak of the fields of the
AttInMetadata struct in shutdown_MultiFuncCall().

Also fix a leak of the SRF result TupleDesc when rescanning a
FunctionScan node. The TupleDesc is allocated in the per-query context
for every call to ExecMakeTableFunctionResult(), so we should free it
after calling that function. Since the SRF might choose to return
a non-expendable TupleDesc, we only free the TupleDesc if it is
not being reference-counted.

Backpatch to 8.3 and 8.2 stable branches.
src/backend/executor/nodeFunctionscan.c
src/backend/utils/fmgr/funcapi.c