Gregory Stark <[EMAIL PROTECTED]> writes: > However I've run into something I didn't expect. It seems merge joins keep a > reference to a tuple *after* they set the mark beyond it. I'm trying to figure > out why this is necessary but I haven't absorbed all of nodeMergejoin yet.
I think at the instant that ExecMarkPos is called, there are likely to still be tuple slots holding references to the previously marked tuple. It might work if you swap the two lines ExecMarkPos(innerPlan); MarkInnerTuple(node->mj_InnerTupleSlot, node); However, the whole thing sounds a bit fragile. If tuplestore_gettuple returns a tuple with shouldfree = false, I think you had better assume that that tuple can be referenced until after the next tuplestore_gettuple call, independently of mark/restore calls. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match