mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Fix dblink and tablefunc to not return with the wrong CurrentMemoryContext.
Per buildfarm results.
This commit is contained in:
@ -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
|
||||
@ -461,6 +450,14 @@ crosstab(PG_FUNCTION_ARGS)
|
||||
errmsg("return and sql tuple descriptions are " \
|
||||
"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
|
||||
|
Reference in New Issue
Block a user