summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-12-29 17:41:09 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-12-29 17:41:09 +0000
commitb1ffbaeddcd05f61b0ad115ec3c13b2a1c65d721 (patch)
tree5a62e6f1f7fc7d13a59f47dcfb2ae5356fe3e48a /src/backend/executor
parentf46b971145c66fe608ca3410a2807a8ab2e5e2f5 (diff)
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.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execQual.c7
-rw-r--r--src/backend/executor/functions.c5
-rw-r--r--src/backend/executor/nodeWindowAgg.c4
-rw-r--r--src/backend/executor/tstoreReceiver.c5
4 files changed, 5 insertions, 16 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 7cac1060afe..86f005b104c 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -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?
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);
}
/*
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 7343cb3752e..3cd71eb9f03 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -27,7 +27,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.6 2009/06/20 18:45:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.6.2.1 2009/12/29 17:41:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -723,7 +723,7 @@ spool_tuples(WindowAggState *winstate, int64 pos)
outerPlan = outerPlanState(winstate);
- /* Must be in query context to call outerplan or touch tuplestore */
+ /* Must be in query context to call outerplan */
oldcontext = MemoryContextSwitchTo(winstate->ss.ps.ps_ExprContext->ecxt_per_query_memory);
while (winstate->spooled_rows <= pos || pos == -1)
diff --git a/src/backend/executor/tstoreReceiver.c b/src/backend/executor/tstoreReceiver.c
index 19f348f13f6..10723a50146 100644
--- a/src/backend/executor/tstoreReceiver.c
+++ b/src/backend/executor/tstoreReceiver.c
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.23 2009/06/11 14:48:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.23.2.1 2009/12/29 17:41:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -94,11 +94,8 @@ static void
tstoreReceiveSlot_notoast(TupleTableSlot *slot, DestReceiver *self)
{
TStoreState *myState = (TStoreState *) self;
- MemoryContext oldcxt = MemoryContextSwitchTo(myState->cxt);
tuplestore_puttupleslot(myState->tstore, slot);
-
- MemoryContextSwitchTo(oldcxt);
}
/*