From b1ffbaeddcd05f61b0ad115ec3c13b2a1c65d721 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 29 Dec 2009 17:41:09 +0000 Subject: 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. --- src/backend/executor/functions.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/backend/executor/functions.c') diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 2f3f4971db9..9d4ca42fdc1 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.135.2.1 2009/12/14 02:16:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.135.2.2 2009/12/29 17:41:09 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -1400,15 +1400,12 @@ static void sqlfunction_receive(TupleTableSlot *slot, DestReceiver *self) { DR_sqlfunction *myState = (DR_sqlfunction *) self; - MemoryContext oldcxt; /* Filter tuple as needed */ slot = ExecFilterJunk(myState->filter, slot); /* Store the filtered tuple into the tuplestore */ - oldcxt = MemoryContextSwitchTo(myState->cxt); tuplestore_puttupleslot(myState->tstore, slot); - MemoryContextSwitchTo(oldcxt); } /* -- cgit v1.2.3