54#define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg)
79#define PG_KEYWORD(kwname, value, category, collabel) value,
90#define YYSTYPE core_YYSTYPE
99#define SET_YYLLOC() (*(yylloc) = yytext - yyextra->scanbuf)
104#define ADVANCE_YYLLOC(delta) ( *(yylloc) += (delta) )
115#define PUSH_YYLLOC() (yyextra->save_yylloc = *(yylloc))
116#define POP_YYLLOC() (*(yylloc) = yyextra->save_yylloc)
118#define startlit() ( yyextra->literallen = 0 )
126#define yyerror(msg) scanner_yyerror(msg, yyscanner)
128#define lexer_errposition() scanner_errposition(*(yylloc), yyscanner)
int errmsg_internal(const char *fmt,...)
#define ereport(elevel,...)
static void const char * fmt
@ BACKSLASH_QUOTE_SAFE_ENCODING
static void check_escape_warning(core_yyscan_t yyscanner)
bool escape_string_warning
static void addlitchar(unsigned char ychar, core_yyscan_t yyscanner)
static int process_integer_literal(const char *token, YYSTYPE *lval, int base)
static char * litbufdup(core_yyscan_t yyscanner)
static void fprintf_to_ereport(const char *fmt, const char *msg)
static void addlit(char *ytext, int yleng, core_yyscan_t yyscanner)
static void addunicode(pg_wchar c, yyscan_t yyscanner)
bool standard_conforming_strings
static unsigned char unescape_single_char(unsigned char c, core_yyscan_t yyscanner)
static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner)
const uint16 ScanKeywordTokens[]
137%option bison-locations
139%option never-interactive
148%option prefix="core_yy"
149%option extra-type="core_yy_extra_type *"
209non_newline_space [ \t\f\v]
213comment ("--"{non_newline}*)
215whitespace ({space}+|{comment})
224special_whitespace ({space}+|{comment}{newline})
225non_newline_whitespace ({non_newline_space}|{comment})
226whitespace_with_newline ({non_newline_whitespace}*{newline}{special_whitespace}*)
230quotecontinue {whitespace_with_newline}{quote}
239quotecontinuefail {whitespace}*"-"?
264xeoctesc [\\][0-7]{1,3}
265xehexesc [\\]x[0-9A-Fa-f]{1,2}
266xeunicode [\\](u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
267xeunicodefail [\\](u[0-9A-Fa-f]{0,3}|U[0-9A-Fa-f]{0,7})
273xqdouble {quote}{quote}
285dolq_start [A-Za-z\200-\377_]
286dolq_cont [A-Za-z\200-\377_0-9]
287dolqdelim \$({dolq_start}{dolq_cont}*)?\$
288dolqfailed \${dolq_start}{dolq_cont}*
297xddouble {dquote}{dquote}
301xuistart [uU]&{dquote}
328xcstart \/\*{op_chars}*
332ident_start [A-Za-z\200-\377_]
333ident_cont [A-Za-z\200-\377_0-9\$]
335identifier {ident_start}{ident_cont}*
366self [,()\[\].;\:\+\-\*\/\%\^<>\=]
367op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%<>\=]
386decinteger {decdigit}(_?{decdigit})*
387hexinteger 0[xX](_?{hexdigit})+
388octinteger 0[oO](_?{octdigit})+
389bininteger 0[bB](_?{bindigit})+
395numeric (({decinteger}\.{decinteger}?)|(\.{decinteger}))
396numericfail {decinteger}\.\.
398real ({decinteger}|{numeric})[Ee][-+]?{decinteger}
399realfail ({decinteger}|{numeric})[Ee][-+]
421integer_junk {decinteger}{identifier}
422numeric_junk {numeric}{identifier}
423real_junk {real}{identifier}
424param_junk \${decdigit}+{identifier}
483 yyerror(
"unterminated /* comment");
503<xb><<EOF>> {
yyerror(
"unterminated bit string literal"); }
517<xh><<EOF>> {
yyerror(
"unterminated hexadecimal string literal"); }
535 return yyextra->keyword_tokens[kwnum];
int ScanKeywordLookup(const char *str, const ScanKeywordList *keywords)
static const char * GetScanKeyword(int n, const ScanKeywordList *keywords)
char * pstrdup(const char *in)
546 yyextra->warn_on_first_escape =
true;
547 yyextra->saw_non_ascii =
false;
549 if (
yyextra->standard_conforming_strings)
556 yyextra->warn_on_first_escape =
false;
557 yyextra->saw_non_ascii =
false;
564 if (!
yyextra->standard_conforming_strings)
566 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
567 errmsg(
"unsafe use of string constant with Unicode escapes"),
568 errdetail(
"String constants with Unicode escapes cannot be used when \"standard_conforming_strings\" is off."),
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define lexer_errposition()
574<xb,xh,xq,xe,xus>{quote} {
583 yyextra->state_before_str_stop = YYSTATE;
586<xqs>{quotecontinue} {
592 BEGIN(
yyextra->state_before_str_stop);
594<xqs>{quotecontinuefail} |
605 switch (
yyextra->state_before_str_stop)
629 yyerror(
"unhandled previous state in xqs");
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
633<xq,xe,xus>{xqdouble} {
643 pg_wchar c = strtoul(yytext + 2, NULL, 16);
663 yyerror(
"invalid Unicode surrogate pair");
static bool is_utf16_surrogate_first(pg_wchar c)
static bool is_utf16_surrogate_second(pg_wchar c)
671 pg_wchar c = strtoul(yytext + 2, NULL, 16);
679 yyerror(
"invalid Unicode surrogate pair");
static pg_wchar surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second)
695 yyerror(
"invalid Unicode surrogate pair");
697<xe,xeu>{xeunicodefail} {
701 (
errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
702 errmsg(
"invalid Unicode escape"),
703 errhint(
"Unicode escapes must be \\uXXXX or \\UXXXXXXXX."),
int errhint(const char *fmt,...)
707 if (yytext[1] ==
'\'')
713 (
errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
714 errmsg(
"unsafe use of \\' in a string literal"),
715 errhint(
"Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
int pg_get_client_encoding(void)
#define PG_ENCODING_IS_CLIENT_ONLY(_enc)
723 unsigned char c = strtoul(yytext + 1, NULL, 8);
#define IS_HIGHBIT_SET(ch)
731 unsigned char c = strtoul(yytext + 2, NULL, 16);
742<xq,xe,xus><<EOF>> {
yyerror(
"unterminated quoted string"); }
758 if (strcmp(yytext,
yyextra->dolqstart) == 0)
void pfree(void *pointer)
787<xdolq><<EOF>> {
yyerror(
"unterminated dollar-quoted string"); }
804 yyerror(
"zero-length delimited identifier");
void truncate_identifier(char *ident, int len, bool warn)
814 yyerror(
"zero-length delimited identifier");
825<xd,xui><<EOF>> {
yyerror(
"unterminated quoted identifier"); }
char * downcase_truncate_identifier(const char *ident, int len, bool warn)
856 return EQUALS_GREATER;
866 return GREATER_EQUALS;
894 char *slashstar = strstr(yytext,
"/*");
895 char *dashdash = strstr(yytext,
"--");
897 if (slashstar && dashdash)
900 if (slashstar > dashdash)
901 slashstar = dashdash;
904 slashstar = dashdash;
906 nchars = slashstar - yytext;
917 (yytext[nchars - 1] ==
'+' ||
918 yytext[nchars - 1] ==
'-'))
922 for (ic = nchars - 2; ic >= 0; ic--)
925 if (
c ==
'~' ||
c ==
'!' ||
c ==
'@' ||
926 c ==
'#' ||
c ==
'^' ||
c ==
'&' ||
927 c ==
'|' ||
c ==
'`' ||
c ==
'?' ||
939 }
while (nchars > 1 &&
940 (yytext[nchars - 1] ==
'+' ||
941 yytext[nchars - 1] ==
'-'));
958 strchr(
",()[].;:+-*/%^<>=", yytext[0]))
968 if (yytext[0] ==
'=' && yytext[1] ==
'>')
969 return EQUALS_GREATER;
970 if (yytext[0] ==
'>' && yytext[1] ==
'=')
971 return GREATER_EQUALS;
972 if (yytext[0] ==
'<' && yytext[1] ==
'=')
974 if (yytext[0] ==
'<' && yytext[1] ==
'>')
976 if (yytext[0] ==
'!' && yytext[1] ==
'=')
1001 yyerror(
"parameter number too large");
int32 pg_strtoint32_safe(const char *s, Node *escontext)
1007 yyerror(
"trailing junk after parameter");
1028 yyerror(
"invalid hexadecimal integer");
1032 yyerror(
"invalid octal integer");
1036 yyerror(
"invalid binary integer");
1040 yylval->str =
pstrdup(yytext);
1051 yylval->str =
pstrdup(yytext);
1056 yyerror(
"trailing junk after numeric literal");
1060 yyerror(
"trailing junk after numeric literal");
1064 yyerror(
"trailing junk after numeric literal");
1068 yyerror(
"trailing junk after numeric literal");
1085 return yyextra->keyword_tokens[kwnum];
1093 yylval->str =
ident;
1118#define yyextra (((struct yyguts_t *) yyscanner)->yyextra_r)
1122#define yylloc (((struct yyguts_t *) yyscanner)->yylloc_r)
1124#define yyleng (((struct yyguts_t *) yyscanner)->yyleng_r)
1226 if (*loc == YY_END_OF_BUFFER_CHAR)
1229 (
errcode(ERRCODE_SYNTAX_ERROR),
1231 errmsg(
"%s at end of input",
_(message)),
1237 (
errcode(ERRCODE_SYNTAX_ERROR),
1239 errmsg(
"%s at or near \"%s\"",
_(message), loc),
1252 const uint16 *keyword_tokens)
1257 if (yylex_init(&scanner) != 0)
1260 core_yyset_extra(yyext, scanner);
1275 yyext->
scanbuf[slen] = yyext->
scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
1276 yy_scan_buffer(yyext->
scanbuf, slen + 2, scanner);
1303 if (
yyextra->scanbuflen >= 8192)
1305 if (
yyextra->literalalloc >= 8192)
1348 int llen =
yyextra->literallen;
1352 memcpy(
new,
yyextra->literalbuf, llen);
1385 yyerror(
"invalid Unicode escape value");
1417 yyextra->saw_non_ascii =
true;
1428 if (
yyextra->warn_on_first_escape &&
yyextra->escape_string_warning)
1430 (
errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1431 errmsg(
"nonstandard use of \\' in a string literal"),
1432 errhint(
"Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
1434 yyextra->warn_on_first_escape =
false;
1436 else if (ychar ==
'\\')
1438 if (
yyextra->warn_on_first_escape &&
yyextra->escape_string_warning)
1440 (
errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1441 errmsg(
"nonstandard use of \\\\ in a string literal"),
1442 errhint(
"Use the escape string syntax for backslashes, e.g., E'\\\\'."),
1444 yyextra->warn_on_first_escape =
false;
1453 if (
yyextra->warn_on_first_escape &&
yyextra->escape_string_warning)
1455 (
errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1456 errmsg(
"nonstandard use of escape in a string literal"),
1457 errhint(
"Use the escape string syntax for escapes, e.g., E'\\r\\n'."),
1459 yyextra->warn_on_first_escape =
false;
ErrorContextCallback * error_context_stack
int errposition(int cursorpos)
int pg_mbstrlen_with_len(const char *mbstr, int limit)
void pg_unicode_to_server(pg_wchar c, unsigned char *s)
void * repalloc(void *pointer, Size size)
static uint32 pg_nextpower2_32(uint32 num)
#define MAX_UNICODE_EQUIVALENT_STRING
static bool is_valid_unicode_codepoint(pg_wchar c)
int scanner_errposition(int location, core_yyscan_t yyscanner)
core_yyscan_t scanner_init(const char *str, core_yy_extra_type *yyext, const ScanKeywordList *keywordlist, const uint16 *keyword_tokens)
void * core_yyrealloc(void *ptr, yy_size_t bytes, core_yyscan_t yyscanner)
static void scb_error_callback(void *arg)
void setup_scanner_errposition_callback(ScannerCallbackState *scbstate, core_yyscan_t yyscanner, int location)
void scanner_finish(core_yyscan_t yyscanner)
void cancel_scanner_errposition_callback(ScannerCallbackState *scbstate)
void * core_yyalloc(yy_size_t bytes, core_yyscan_t yyscanner)
void core_yyfree(void *ptr, core_yyscan_t yyscanner)
void scanner_yyerror(const char *message, core_yyscan_t yyscanner)
struct ErrorContextCallback * previous
void(* callback)(void *arg)
ErrorContextCallback errcallback