Commit a7920b87 authored by Fujii Masao's avatar Fujii Masao

Add note about how to make the SRF detoasted arguments live accross calls.

Andrew Gierth and Ali Akbar
parent f5ef00ae
...@@ -2981,6 +2981,20 @@ SRF_RETURN_DONE(funcctx) ...@@ -2981,6 +2981,20 @@ SRF_RETURN_DONE(funcctx)
<structfield>multi_call_memory_ctx</> while doing the first-call setup. <structfield>multi_call_memory_ctx</> while doing the first-call setup.
</para> </para>
<warning>
<para>
While the actual arguments to the function remain unchanged between
calls, if you detoast the argument values (which is normally done
transparently by the
<function>PG_GETARG_<replaceable>xxx</replaceable></function> 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 <structfield>user_fctx</>, you must either copy them into the
<structfield>multi_call_memory_ctx</> after detoasting, or ensure
that you detoast the values only in that context.
</para>
</warning>
<para> <para>
A complete pseudo-code example looks like the following: A complete pseudo-code example looks like the following:
<programlisting> <programlisting>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment