Fix several memory s when rescanning SRFs. Arrange for an SRF's
authorNeil Conway <[email protected]>
Fri, 29 Feb 2008 02:49:39 +0000 (02:49 +0000)
committerNeil Conway <[email protected]>
Fri, 29 Feb 2008 02:49:39 +0000 (02:49 +0000)
commitff428cdeda20b8b1cf465f8c6cd27da9b2abe9b7
treef5e986961f4b9d7cab06b679c666e3da4b590bff
parentb13635ce59ca44cc0bc1dcccd9bf7e086fa13ac7
Fix several memory s 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 ing 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  of the fields of the
AttInMetadata struct in shutdown_MultiFuncCall().

Also fix a  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.

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