Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d8e511f

Browse files
committed
Ensure that the result tuple of an EvalPlanQual cycle gets materialized
before we zap the input tuple. Otherwise, pass-by-reference columns of the result slot are likely to contain just references to the input tuple, leading to big trouble if the pfree'd space is reused. Per trouble report from Jaime Casanova. This is a new bug in the recent rewrite of EvalPlanQual, so nothing to back-patch.
1 parent f1325ce commit d8e511f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/executor/execMain.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.336 2009/12/09 21:57:51 tgl Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.337 2009/12/11 18:14:43 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -1407,6 +1407,16 @@ EvalPlanQual(EState *estate, EPQState *epqstate,
14071407
*/
14081408
slot = EvalPlanQualNext(epqstate);
14091409

1410+
/*
1411+
* If we got a tuple, force the slot to materialize the tuple so that
1412+
* it is not dependent on any local state in the EPQ query (in particular,
1413+
* it's highly likely that the slot contains references to any pass-by-ref
1414+
* datums that may be present in copyTuple). As with the next step,
1415+
* this is to guard against early re-use of the EPQ query.
1416+
*/
1417+
if (!TupIsNull(slot))
1418+
(void) ExecMaterializeSlot(slot);
1419+
14101420
/*
14111421
* Clear out the test tuple. This is needed in case the EPQ query
14121422
* is re-used to test a tuple for a different relation. (Not clear

0 commit comments

Comments
 (0)