* Check the updated version of a tuple to see if we want to process it under * READ COMMITTED rules. * * epqstate - state for EvalPlanQual rechecking * relation - table containing tuple * rti - rangetable index of table containing tuple * inputslot - tuple for processing - this can be the slot from * EvalPlanQualSlot(), for the increased efficiency. * * This tests whether the tuple in in
| 3619 | * NULL if we determine we shouldn't process the row. |
| 3620 | */ |
| 3621 | TupleTableSlot * |
| 3622 | EvalPlanQual(EPQState *epqstate, Relation relation, |
| 3623 | Index rti, TupleTableSlot *inputslot) |
| 3624 | { |
| 3625 | TupleTableSlot *slot; |
| 3626 | TupleTableSlot *testslot; |
| 3627 | |
| 3628 | Assert(rti > 0); |
| 3629 | |
| 3630 | /* |
| 3631 | * Need to run a recheck subquery. Initialize or reinitialize EPQ state. |
| 3632 | */ |
| 3633 | EvalPlanQualBegin(epqstate); |
| 3634 | |
| 3635 | /* |
| 3636 | * Callers will often use the EvalPlanQualSlot to store the tuple to avoid |
| 3637 | * an unnecessary copy. |
| 3638 | */ |
| 3639 | testslot = EvalPlanQualSlot(epqstate, relation, rti); |
| 3640 | if (testslot != inputslot) |
| 3641 | ExecCopySlot(testslot, inputslot); |
| 3642 | |
| 3643 | /* |
| 3644 | * Run the EPQ query. We assume it will return at most one tuple. |
| 3645 | */ |
| 3646 | slot = EvalPlanQualNext(epqstate); |
| 3647 | |
| 3648 | /* |
| 3649 | * If we got a tuple, force the slot to materialize the tuple so that it |
| 3650 | * is not dependent on any local state in the EPQ query (in particular, |
| 3651 | * it's highly likely that the slot contains references to any pass-by-ref |
| 3652 | * datums that may be present in copyTuple). As with the next step, this |
| 3653 | * is to guard against early re-use of the EPQ query. |
| 3654 | */ |
| 3655 | if (!TupIsNull(slot)) |
| 3656 | ExecMaterializeSlot(slot); |
| 3657 | |
| 3658 | /* |
| 3659 | * Clear out the test tuple. This is needed in case the EPQ query is |
| 3660 | * re-used to test a tuple for a different relation. (Not clear that can |
| 3661 | * really happen, but let's be safe.) |
| 3662 | */ |
| 3663 | ExecClearTuple(testslot); |
| 3664 | |
| 3665 | return slot; |
| 3666 | } |
| 3667 | |
| 3668 | /* |
| 3669 | * EvalPlanQualInit -- initialize during creation of a plan state node |
no test coverage detected