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

Function MakeTidOpExpr

src/backend/executor/nodeTidrangescan.c:52–95  ·  view source on GitHub ↗

* For the given 'expr', build and return an appropriate TidOpExpr taking into * account the expr's operator and operand order. */

Source from the content-addressed store, hash-verified

50 * account the expr's operator and operand order.
51 */
52static TidOpExpr *
53MakeTidOpExpr(OpExpr *expr, TidRangeScanState *tidstate)
54{
55 Node *arg1 = get_leftop((Expr *) expr);
56 Node *arg2 = get_rightop((Expr *) expr);
57 ExprState *exprstate = NULL;
58 bool invert = false;
59 TidOpExpr *tidopexpr;
60
61 if (IsCTIDVar(arg1))
62 exprstate = ExecInitExpr((Expr *) arg2, &tidstate->ss.ps);
63 else if (IsCTIDVar(arg2))
64 {
65 exprstate = ExecInitExpr((Expr *) arg1, &tidstate->ss.ps);
66 invert = true;
67 }
68 else
69 elog(ERROR, "could not identify CTID variable");
70
71 tidopexpr = (TidOpExpr *) palloc(sizeof(TidOpExpr));
72 tidopexpr->inclusive = false; /* for now */
73
74 switch (expr->opno)
75 {
76 case TIDLessEqOperator:
77 tidopexpr->inclusive = true;
78 /* fall through */
79 case TIDLessOperator:
80 tidopexpr->exprtype = invert ? TIDEXPR_LOWER_BOUND : TIDEXPR_UPPER_BOUND;
81 break;
82 case TIDGreaterEqOperator:
83 tidopexpr->inclusive = true;
84 /* fall through */
85 case TIDGreaterOperator:
86 tidopexpr->exprtype = invert ? TIDEXPR_UPPER_BOUND : TIDEXPR_LOWER_BOUND;
87 break;
88 default:
89 elog(ERROR, "could not identify CTID operator");
90 }
91
92 tidopexpr->exprstate = exprstate;
93
94 return tidopexpr;
95}
96
97/*
98 * Extract the qual subexpressions that yield TIDs to search for,

Callers 1

TidExprListCreateFunction · 0.85

Calls 5

get_leftopFunction · 0.85
get_rightopFunction · 0.85
IsCTIDVarFunction · 0.85
ExecInitExprFunction · 0.85
pallocFunction · 0.50

Tested by

no test coverage detected