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

Function plpgsql_location_to_lineno

src/pl/plpgsql/src/pl_scanner.c:540–561  ·  view source on GitHub ↗

* Given a location (a byte offset in the function source text), * return a line number. * * We expect that this is typically called for a sequence of increasing * location values, so optimize accordingly by tracking the endpoints * of the "current" line. */

Source from the content-addressed store, hash-verified

538 * of the "current" line.
539 */
540int
541plpgsql_location_to_lineno(int location)
542{
543 const char *loc;
544
545 if (location < 0 || scanorig == NULL)
546 return 0; /* garbage in, garbage out */
547 loc = scanorig + location;
548
549 /* be correct, but not fast, if input location goes backwards */
550 if (loc < cur_line_start)
551 location_lineno_init();
552
553 while (cur_line_end != NULL && loc > cur_line_end)
554 {
555 cur_line_start = cur_line_end + 1;
556 cur_line_num++;
557 cur_line_end = strchr(cur_line_start, '\n');
558 }
559
560 return cur_line_num;
561}
562
563/* initialize or reset the state for plpgsql_location_to_lineno */
564static void

Callers

nothing calls this directly

Calls 1

location_lineno_initFunction · 0.85

Tested by

no test coverage detected