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

Function executor_errposition

src/backend/executor/execUtils.c:955–970  ·  view source on GitHub ↗

* executor_errposition * Report an execution-time cursor position, if possible. * * This is expected to be used within an ereport() call. The return value * is a dummy (always 0, in fact). * * The locations stored in parsetrees are byte offsets into the source string. * We have to convert them to 1-based character indexes for reporting to * clients. (We do things this way to avoid unnec

Source from the content-addressed store, hash-verified

953 * expensive than storing token offsets.)
954 */
955int
956executor_errposition(EState *estate, int location)
957{
958 int pos;
959
960 /* No-op if location was not provided */
961 if (location < 0)
962 return 0;
963 /* Can't do anything if source text is not available */
964 if (estate == NULL || estate->es_sourceText == NULL)
965 return 0;
966 /* Convert offset to character number */
967 pos = pg_mbstrlen_with_len(estate->es_sourceText, location) + 1;
968 /* And pass it to the ereport mechanism */
969 return errposition(pos);
970}
971
972/*
973 * Register a shutdown callback in an ExprContext.

Callers 3

init_sexprFunction · 0.85
ExecInitFuncFunction · 0.85
ExecInitSubscriptingRefFunction · 0.85

Calls 2

pg_mbstrlen_with_lenFunction · 0.85
errpositionFunction · 0.50

Tested by

no test coverage detected