MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecEvalCurrentOfExpr

Function ExecEvalCurrentOfExpr

src/backend/executor/execExprInterp.c:2617–2653  ·  view source on GitHub ↗

* Raise error if a CURRENT OF expression is evaluated. * * GPDB: * Constant folding must have bound observed values of gp_segment_id, * ctid, and tableoid into the CurrentOfExpr for this function's * consumption. */

Source from the content-addressed store, hash-verified

2615 * consumption.
2616 */
2617void
2618ExecEvalCurrentOfExpr(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
2619{
2620 CurrentOfExpr *cexpr = (CurrentOfExpr *) state->expr;
2621 bool result = false;
2622 TupleTableSlot *slot;
2623
2624 Assert(cexpr->cvarno != INNER_VAR);
2625 Assert(cexpr->cvarno != OUTER_VAR);
2626
2627 slot = econtext->ecxt_scantuple;
2628 Assert(!TupIsNull(slot));
2629
2630 /*
2631 * The currently scanned tuple must use heap storage for it to possibly
2632 * satisfy the CURRENT OF qualification. Despite our grand attempts during
2633 * parsing and constant folding to demand heap storage, the scanning of an
2634 * AO part is still possible, when the current row uses heap storage, but the
2635 * CURRENT OF invocation uses an unpruned scan of the partition table, yielding
2636 * tuples from the AO parts before the desired heap tuple.
2637 */
2638 if (slot->tts_ops == &TTSOpsHeapTuple ||
2639 slot->tts_ops == &TTSOpsBufferHeapTuple)
2640 {
2641 ItemPointerData cursor_tid;
2642
2643 if (execCurrentOf(cexpr, econtext,
2644 slot->tts_tableOid,
2645 &cursor_tid))
2646 {
2647 if (ItemPointerEquals(&cursor_tid, &slot->tts_tid))
2648 result = true;
2649 }
2650 }
2651 *op->resvalue = result;
2652 *op->resnull = false;
2653}
2654
2655/*
2656 * Evaluate NextValueExpr.

Callers 1

ExecInterpExprFunction · 0.85

Calls 2

execCurrentOfFunction · 0.85
ItemPointerEqualsFunction · 0.85

Tested by

no test coverage detected