From: Fujii Masao Date: Thu, 26 Feb 2015 06:48:07 +0000 (+0900) Subject: Add note about how to make the SRF detoasted arguments live accross calls. X-Git-Tag: REL9_5_ALPHA1~705 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7920b872fff36668a2d33157609024b851b5c2e;p=postgresql Add note about how to make the SRF detoasted arguments live accross calls. Andrew Gierth and Ali Akbar --- diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 97a56562d3..b85f2adc45 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -2981,6 +2981,20 @@ SRF_RETURN_DONE(funcctx) multi_call_memory_ctx while doing the first-call setup. + + + While the actual arguments to the function remain unchanged between + calls, if you detoast the argument values (which is normally done + transparently by the + PG_GETARG_xxx macro) + in the transient context then the detoasted copies will be freed on + each cycle. Accordingly, if you keep references to such values in + your user_fctx, you must either copy them into the + multi_call_memory_ctx after detoasting, or ensure + that you detoast the values only in that context. + + + A complete pseudo-code example looks like the following: