-<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.141 2009/11/23 21:41:20 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.142 2009/11/30 15:49:35 petere Exp $ -->
<sect1 id="xfunc">
<title>User-Defined Functions</title>
{
FuncCallContext *funcctx;
Datum result;
- MemoryContext oldcontext;
<replaceable>further declarations as needed</replaceable>
if (SRF_IS_FIRSTCALL())
{
+ MemoryContext oldcontext;
+
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
/* One-time setup code appears here: */
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 */