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

Function TidRangeEval

src/backend/executor/nodeTidrangescan.c:132–205  ·  view source on GitHub ↗

---------------------------------------------------------------- * TidRangeEval * * Compute and set node's block and offset range to scan by evaluating * the trss_tidexprs. Returns false if we detect the range cannot * contain any tuples. Returns true if it's possible for the range to * contain tuples. * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

130 * ----------------------------------------------------------------
131 */
132static bool
133TidRangeEval(TidRangeScanState *node)
134{
135 ExprContext *econtext = node->ss.ps.ps_ExprContext;
136 ItemPointerData lowerBound;
137 ItemPointerData upperBound;
138 ListCell *l;
139
140 /*
141 * Set the upper and lower bounds to the absolute limits of the range of
142 * the ItemPointer type. Below we'll try to narrow this range on either
143 * side by looking at the TidOpExprs.
144 */
145 ItemPointerSet(&lowerBound, 0, 0);
146 ItemPointerSet(&upperBound, InvalidBlockNumber, PG_UINT16_MAX);
147
148 foreach(l, node->trss_tidexprs)
149 {
150 TidOpExpr *tidopexpr = (TidOpExpr *) lfirst(l);
151 ItemPointer itemptr;
152 bool isNull;
153
154 /* Evaluate this bound. */
155 itemptr = (ItemPointer)
156 DatumGetPointer(ExecEvalExprSwitchContext(tidopexpr->exprstate,
157 econtext,
158 &isNull));
159
160 /* If the bound is NULL, *nothing* matches the qual. */
161 if (isNull)
162 return false;
163
164 if (tidopexpr->exprtype == TIDEXPR_LOWER_BOUND)
165 {
166 ItemPointerData lb;
167
168 ItemPointerCopy(itemptr, &lb);
169
170 /*
171 * Normalize non-inclusive ranges to become inclusive. The
172 * resulting ItemPointer here may not be a valid item pointer.
173 */
174 if (!tidopexpr->inclusive)
175 ItemPointerInc(&lb);
176
177 /* Check if we can narrow the range using this qual */
178 if (ItemPointerCompare(&lb, &lowerBound) > 0)
179 ItemPointerCopy(&lb, &lowerBound);
180 }
181
182 else if (tidopexpr->exprtype == TIDEXPR_UPPER_BOUND)
183 {
184 ItemPointerData ub;
185
186 ItemPointerCopy(itemptr, &ub);
187
188 /*
189 * Normalize non-inclusive ranges to become inclusive. The

Callers 1

TidRangeNextFunction · 0.85

Calls 5

ItemPointerIncFunction · 0.85
ItemPointerCompareFunction · 0.85
ItemPointerDecFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected