*** pgsql/src/backend/executor/execMain.c 2009/12/09 21:57:51 1.336 --- pgsql/src/backend/executor/execMain.c 2009/12/11 18:14:43 1.337 *************** *** 26,32 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.335 2009/11/20 20:38:10 tgl Exp $ * *------------------------------------------------------------------------- */ --- 26,32 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.336 2009/12/09 21:57:51 tgl Exp $ * *------------------------------------------------------------------------- */ *************** EvalPlanQual(EState *estate, EPQState *e *** 1408,1413 **** --- 1408,1423 ---- slot = EvalPlanQualNext(epqstate); /* + * If we got a tuple, force the slot to materialize the tuple so that + * it is not dependent on any local state in the EPQ query (in particular, + * it's highly likely that the slot contains references to any pass-by-ref + * datums that may be present in copyTuple). As with the next step, + * this is to guard against early re-use of the EPQ query. + */ + if (!TupIsNull(slot)) + (void) ExecMaterializeSlot(slot); + + /* * Clear out the test tuple. This is needed in case the EPQ query * is re-used to test a tuple for a different relation. (Not clear * that can really happen, but let's be safe.)