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

Function plpgsql_yyerror

src/pl/plpgsql/src/pl_scanner.c:501–530  ·  view source on GitHub ↗

* plpgsql_yyerror * Report a lexer or grammar error. * * The message's cursor position refers to the current token (the one * last returned by plpgsql_yylex()). * This is OK for syntax error messages from the Bison parser, because Bison * parsers report error as soon as the first unparsable token is reached. * Beware of using yyerror for other purposes, as the cursor position might * be m

Source from the content-addressed store, hash-verified

499 * be misleading!
500 */
501void
502plpgsql_yyerror(const char *message)
503{
504 char *yytext = core_yy.scanbuf + plpgsql_yylloc;
505
506 if (*yytext == '\0')
507 {
508 ereport(ERROR,
509 (errcode(ERRCODE_SYNTAX_ERROR),
510 /* translator: %s is typically the translation of "syntax error" */
511 errmsg("%s at end of input", _(message)),
512 plpgsql_scanner_errposition(plpgsql_yylloc)));
513 }
514 else
515 {
516 /*
517 * If we have done any lookahead then flex will have restored the
518 * character after the end-of-token. Zap it again so that we report
519 * only the single token here. This modifies scanbuf but we no longer
520 * care about that.
521 */
522 yytext[plpgsql_yyleng] = '\0';
523
524 ereport(ERROR,
525 (errcode(ERRCODE_SYNTAX_ERROR),
526 /* translator: first %s is typically the translation of "syntax error" */
527 errmsg("%s at or near \"%s\"", _(message), yytext),
528 plpgsql_scanner_errposition(plpgsql_yylloc)));
529 }
530}
531
532/*
533 * Given a location (a byte offset in the function source text),

Callers

nothing calls this directly

Calls 3

errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected