From: Peter Eisentraut Date: Mon, 30 Nov 2009 15:49:35 +0000 (+0000) Subject: In SRF example, move oldcontext variable definition into the FIRSTCALL X-Git-Tag: REL8_5_ALPHA3~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb1e8bea020fb3d83df308bfd263968fb0374ff7;p=postgresql In SRF example, move oldcontext variable definition into the FIRSTCALL branch, which is how most actual code is actually structured. Also fix slight whitespace misalignment. --- diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 7a5fa4a0d9..b0ef51c7df 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,4 +1,4 @@ - + User-Defined Functions @@ -3034,11 +3034,12 @@ my_set_returning_function(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; Datum result; - MemoryContext oldcontext; further declarations as needed if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext; + funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* One-time setup code appears here: */ @@ -3088,9 +3089,9 @@ retcomposite(PG_FUNCTION_ARGS) TupleDesc tupdesc; AttInMetadata *attinmeta; - /* stuff done only on the first call of the function */ - if (SRF_IS_FIRSTCALL()) - { + /* stuff done only on the first call of the function */ + if (SRF_IS_FIRSTCALL()) + { MemoryContext oldcontext; /* create a function context for cross-call persistence */