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

Function recompute_limits

src/backend/executor/nodeLimit.c:377–449  ·  view source on GitHub ↗

* Evaluate the limit/offset expressions --- done at startup or rescan. * * This is also a handy place to reset the current-position state info. */

Source from the content-addressed store, hash-verified

375 * This is also a handy place to reset the current-position state info.
376 */
377static void
378recompute_limits(LimitState *node)
379{
380 ExprContext *econtext = node->ps.ps_ExprContext;
381 Datum val;
382 bool isNull;
383
384 if (node->limitOffset)
385 {
386 val = ExecEvalExprSwitchContext(node->limitOffset,
387 econtext,
388 &isNull);
389 /* Interpret NULL offset as no offset */
390 if (isNull)
391 node->offset = 0;
392 else
393 {
394 node->offset = DatumGetInt64(val);
395 if (node->offset < 0)
396 ereport(ERROR,
397 (errcode(ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE),
398 errmsg("OFFSET must not be negative")));
399 }
400 }
401 else
402 {
403 /* No OFFSET supplied */
404 node->offset = 0;
405 }
406
407 if (node->limitCount)
408 {
409 val = ExecEvalExprSwitchContext(node->limitCount,
410 econtext,
411 &isNull);
412 /* Interpret NULL count as no count (LIMIT ALL) */
413 if (isNull)
414 {
415 node->count = 0;
416 node->noCount = true;
417 }
418 else
419 {
420 node->count = DatumGetInt64(val);
421 if (node->count < 0)
422 ereport(ERROR,
423 (errcode(ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE),
424 errmsg("LIMIT must not be negative")));
425 node->noCount = false;
426 }
427 }
428 else
429 {
430 /* No COUNT supplied */
431 node->count = 0;
432 node->noCount = true;
433 }
434

Callers 2

ExecLimit_gutsFunction · 0.85
ExecReScanLimitFunction · 0.85

Calls 6

DatumGetInt64Function · 0.85
ExecSetTupleBoundFunction · 0.85
compute_tuples_neededFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected