1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Previous fix for temporary file management broke returning a set from

PL/pgSQL function within an exception handler. Make sure we use the right
resource owner when we create the tuplestore to hold returned tuples.

Simplify tuplestore API so that the caller doesn't need to be in the right
memory context when calling tuplestore_put* functions. tuplestore.c
automatically switches to the memory context used when the tuplestore was
created. Tuplesort was already modified like this earlier. This patch also
removes the now useless MemoryContextSwitch calls from callers.

Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like
the previous patch that broke this.
This commit is contained in:
Heikki Linnakangas
2009-12-29 17:41:09 +00:00
parent f46b971145
commit b1ffbaeddc
13 changed files with 74 additions and 99 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.250.2.1 2009/12/14 02:16:03 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.250.2.2 2009/12/29 17:41:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@ -2000,15 +2000,10 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
tmptup.t_data = td;
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_query_memory);
tuplestore_puttuple(tupstore, &tmptup);
}
else
{
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_query_memory);
tuplestore_putvalues(tupstore, tupdesc, &result, &fcinfo.isnull);
}
MemoryContextSwitchTo(oldcontext);
/*
* Are we done?