Skip to content

Commit a7920b8

Browse files
committed
Add note about how to make the SRF detoasted arguments live accross calls.
Andrew Gierth and Ali Akbar
1 parent f5ef00a commit a7920b8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/src/sgml/xfunc.sgml

+14
Original file line numberDiff line numberDiff line change
@@ -2981,6 +2981,20 @@ SRF_RETURN_DONE(funcctx)
29812981
<structfield>multi_call_memory_ctx</> while doing the first-call setup.
29822982
</para>
29832983

2984+
<warning>
2985+
<para>
2986+
While the actual arguments to the function remain unchanged between
2987+
calls, if you detoast the argument values (which is normally done
2988+
transparently by the
2989+
<function>PG_GETARG_<replaceable>xxx</replaceable></function> macro)
2990+
in the transient context then the detoasted copies will be freed on
2991+
each cycle. Accordingly, if you keep references to such values in
2992+
your <structfield>user_fctx</>, you must either copy them into the
2993+
<structfield>multi_call_memory_ctx</> after detoasting, or ensure
2994+
that you detoast the values only in that context.
2995+
</para>
2996+
</warning>
2997+
29842998
<para>
29852999
A complete pseudo-code example looks like the following:
29863000
<programlisting>

0 commit comments

Comments
 (0)