From 25bf7f8b9b3ce0f04b498988bb98d9d5cf9bad67 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 27 Mar 2009 18:30:21 +0000 Subject: Fix possible failures when a tuplestore switches from in-memory to on-disk mode while callers hold pointers to in-memory tuples. I reported this for the case of nodeWindowAgg's primary scan tuple, but inspection of the code shows that all of the calls in nodeWindowAgg and nodeCtescan are at risk. For the moment, fix it with a rather brute-force approach of copying whenever one of the at-risk callers requests a tuple. Later we might think of some sort of reference-count approach to reduce tuple copying. --- src/backend/executor/functions.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/executor/functions.c') diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index a8673b1f607..f71807835f2 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.132 2009/01/02 20:42:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.133 2009/03/27 18:30:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -736,7 +736,7 @@ fmgr_sql(PG_FUNCTION_ARGS) /* Re-use the junkfilter's output slot to fetch back the tuple */ Assert(fcache->junkFilter); slot = fcache->junkFilter->jf_resultSlot; - if (!tuplestore_gettupleslot(fcache->tstore, true, slot)) + if (!tuplestore_gettupleslot(fcache->tstore, true, false, slot)) elog(ERROR, "failed to fetch lazy-eval tuple"); /* Extract the result as a datum, and copy out from the slot */ result = postquel_get_single_result(slot, fcinfo, @@ -822,7 +822,7 @@ fmgr_sql(PG_FUNCTION_ARGS) { /* Re-use the junkfilter's output slot to fetch back the tuple */ slot = fcache->junkFilter->jf_resultSlot; - if (tuplestore_gettupleslot(fcache->tstore, true, slot)) + if (tuplestore_gettupleslot(fcache->tstore, true, false, slot)) result = postquel_get_single_result(slot, fcinfo, fcache, oldcontext); else -- cgit v1.2.3