Index: source/src/backend/executor/nodeMaterial.c =================================================================== RCS file: /home/neilc/postgres/cvs_root/pgsql/src/backend/executor/nodeMaterial.c,v retrieving revision 1.59 diff -p -c -r1.59 nodeMaterial.c *** source/src/backend/executor/nodeMaterial.c 21 May 2007 17:57:33 -0000 1.59 --- source/src/backend/executor/nodeMaterial.c 16 Oct 2007 04:00:46 -0000 *************** ExecMaterial(MaterialState *node) *** 98,103 **** --- 98,105 ---- eof_tuplestore = true; } + ExecClearTuple(slot); + /* * If necessary, try to fetch another row from the subplan. * *************** ExecMaterial(MaterialState *node) *** 124,147 **** } /* ! * Append returned tuple to tuplestore. NOTE: because the tuplestore ! * is certainly in EOF state, its read position will move forward over ! * the added tuple. This is what we want. */ if (tuplestorestate) tuplestore_puttupleslot(tuplestorestate, outerslot); ! /* ! * And return a copy of the tuple. (XXX couldn't we just return the ! * outerslot?) ! */ ! return ExecCopySlot(slot, outerslot); } ! /* ! * Nothing left ... ! */ ! return ExecClearTuple(slot); } /* ---------------------------------------------------------------- --- 126,143 ---- } /* ! * Append a copy of the returned tuple to tuplestore. NOTE: because ! * the tuplestore is certainly in EOF state, its read position will ! * move forward over the added tuple. This is what we want. */ if (tuplestorestate) tuplestore_puttupleslot(tuplestorestate, outerslot); ! return outerslot; } ! /* Nothing left, return empty slot */ ! return slot; } /* ----------------------------------------------------------------