diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-30 23:23:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-30 23:23:52 +0000 |
commit | 76cc2fe6a1817874011aebe564e83c71ad8cfc2d (patch) | |
tree | 3f41efe69722b7ccb3f7bc5dfc5177f7e8147c6d /contrib/tablefunc/tablefunc.c | |
parent | c1f3073333d01987ac9c3e5f6c197b9e2afc3ba9 (diff) | |
download | postgresql-76cc2fe6a1817874011aebe564e83c71ad8cfc2d.tar.gz postgresql-76cc2fe6a1817874011aebe564e83c71ad8cfc2d.zip |
Fix dblink and tablefunc to not return with the wrong CurrentMemoryContext.
Per buildfarm results.
Diffstat (limited to 'contrib/tablefunc/tablefunc.c')
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 1f4a6dd9ddd..28b7a64f439 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.55 2008/10/29 00:00:38 tgl Exp $ + * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.56 2008/11/30 23:23:52 tgl Exp $ * * * tablefunc @@ -381,11 +381,6 @@ crosstab(PG_FUNCTION_ARGS) /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); - /* - * switch to memory context appropriate for multiple function calls - */ - oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - /* Connect to SPI manager */ if ((ret = SPI_connect()) < 0) /* internal error */ @@ -426,9 +421,6 @@ crosstab(PG_FUNCTION_ARGS) SRF_RETURN_DONE(funcctx); } - /* SPI switches context on us, so reset it */ - MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - /* get a tuple descriptor for our result type */ switch (get_call_result_type(fcinfo, NULL, &tupdesc)) { @@ -448,9 +440,6 @@ crosstab(PG_FUNCTION_ARGS) break; } - /* make sure we have a persistent copy of the tupdesc */ - tupdesc = CreateTupleDescCopy(tupdesc); - /* * Check that return tupdesc is compatible with the data we got from * SPI, at least based on number and type of attributes @@ -462,6 +451,14 @@ crosstab(PG_FUNCTION_ARGS) "incompatible"))); /* + * switch to memory context appropriate for multiple function calls + */ + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + + /* make sure we have a persistent copy of the tupdesc */ + tupdesc = CreateTupleDescCopy(tupdesc); + + /* * Generate attribute metadata needed later to produce tuples from raw * C strings */ |