59#define LEXRES_BACKSLASH 2
62#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
static void psqlscan_track_identifier(PsqlScanState state, const char *identifier)
72%option never-interactive
78%option prefix="psql_yy"
84%option extra-type="PsqlScanState"
153non_newline_space [ \t\f\v]
157comment ("--"{non_newline}*)
159whitespace ({space}+|{comment})
168special_whitespace ({space}+|{comment}{newline})
169non_newline_whitespace ({non_newline_space}|{comment})
170whitespace_with_newline ({non_newline_whitespace}*{newline}{special_whitespace}*)
174quotecontinue {whitespace_with_newline}{quote}
183quotecontinuefail {whitespace}*"-"?
208xeoctesc [\\][0-7]{1,3}
209xehexesc [\\]x[0-9A-Fa-f]{1,2}
210xeunicode [\\](u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
211xeunicodefail [\\](u[0-9A-Fa-f]{0,3}|U[0-9A-Fa-f]{0,7})
217xqdouble {quote}{quote}
229dolq_start [A-Za-z\200-\377_]
230dolq_cont [A-Za-z\200-\377_0-9]
231dolqdelim \$({dolq_start}{dolq_cont}*)?\$
232dolqfailed \${dolq_start}{dolq_cont}*
241xddouble {dquote}{dquote}
245xuistart [uU]&{dquote}
272xcstart \/\*{op_chars}*
276ident_start [A-Za-z\200-\377_]
277ident_cont [A-Za-z\200-\377_0-9\$]
279identifier {ident_start}{ident_cont}*
312self [,()\[\].;\:\|\+\-\*\/\%\^<>\=]
313op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%<>\=]
332decinteger {decdigit}(_?{decdigit})*
333hexinteger 0[xX](_?{hexdigit})+
334octinteger 0[oO](_?{octdigit})+
335bininteger 0[bB](_?{bindigit})+
341numeric (({decinteger}\.{decinteger}?)|(\.{decinteger}))
342numericfail {decinteger}\.\.
344real ({decinteger}|{numeric})[Ee][-+]?{decinteger}
345realfail ({decinteger}|{numeric})[Ee][-+]
367integer_junk {decinteger}{identifier}
368numeric_junk {numeric}{identifier}
369real_junk {real}{identifier}
370param_junk \${decdigit}+{identifier}
373variable_char [A-Za-z\200-\377_0-9]
395 PQExpBuffer output_buf =
cur_state->output_buf;
404 BEGIN(cur_state->start_state);
415 if (output_buf->len > 0)
497<xb,xh,xq,xe,xus>{quote} {
510<xqs>{quotecontinue} {
519<xqs>{quotecontinuefail} |
531<xq,xe,xus>{xqdouble} {
char * pg_strdup(const char *in)
void psqlscan_emit(PsqlScanState state, const char *txt, int len)
#define pg_log_warning(...)
char * psqlscan_extract_substring(PsqlScanState state, const char *txt, int len)
void psqlscan_push_new_buffer(PsqlScanState state, const char *newstr, const char *varname)
bool psqlscan_var_is_current_source(PsqlScanState state, const char *varname)
void psqlscan_escape_variable(PsqlScanState state, const char *txt, int len, PsqlScanQuoteType quote)
765:\"{variable_char}+\" {
770:\{\?{variable_char}+\} {
void psqlscan_test_variable(PsqlScanState state, const char *txt, int len)
791:\{\?{variable_char}* {
841 (
yytext[nchars - 1] ==
'+' ||
842 yytext[nchars - 1] ==
'-'))
846 for (
ic = nchars - 2;
ic >= 0;
ic--)
849 if (
c ==
'~' ||
c ==
'!' ||
c ==
'@' ||
850 c ==
'#' ||
c ==
'^' ||
c ==
'&' ||
851 c ==
'|' ||
c ==
'`' ||
c ==
'?' ||
863 }
while (nchars > 1 &&
864 (
yytext[nchars - 1] ==
'+' ||
865 yytext[nchars - 1] ==
'-'));
void psqlscan_select_top_buffer(PsqlScanState state)
void psqlscan_pop_buffer_stack(PsqlScanState state)
998 return idents[0] ==
'c' &&
999 (idents[1] ==
'f' || idents[1] ==
'p' ||
1000 (idents[1] ==
'o' && idents[2] ==
'r' &&
1001 (idents[3] ==
'f' || idents[3] ==
'p')));
1021 if (
state->paren_depth != 0)
1025 if (
state->init_idents_count == 0)
1028 state->sub_idents_count = 0;
1036 &
state->init_idents_count);
1044 state->init_idents[1] ==
's');
1046 state->begin_depth == 0)
1051 state->sub_idents_count = 0;
1058 &
state->sub_idents_count);
1069 state->begin_depth++;
1076 if (
state->begin_depth >= 1)
1077 state->begin_depth++;
1081 if (
state->begin_depth > 0)
1082 state->begin_depth--;
1101 state->callbacks = callbacks;
1166 state->std_strings = std_strings;
1171 state->scanline = line;
1178 state->cur_line_no = 0;
1238 if (
state->cur_line_no == 0)
1239 state->cur_line_no = 1;
1247 switch (
state->start_state)
1251 if (
state->paren_depth > 0)
1256 else if (
state->begin_depth > 0)
1349 if (
state->scanbufhandle)
1372 state->paren_depth = 0;
1374 if (
state->dolqstart)
1377 state->begin_depth = 0;
1378 state->init_idents_count = 0;
1430 int *lineno,
int *offset)
1439 if (
state->cur_line_no == 0)
1452 state->cur_line_no++;
1458 *lineno =
state->cur_line_no;
1459 *offset =
state->cur_line_ptr -
state->scanbuf;
1469 const char *varname)
1485 if (
state->safe_encoding)
1580 if (
state->safe_encoding)
1615 if (
state->safe_encoding)
1620 const char *reference =
state->refline;
1623 reference += (
txt -
state->curline);
1625 for (
i = 0;
i <
len;
i++)
1629 if (
ch == (
char) 0xFF)
1647 if (
state->safe_encoding)
1652 const char *reference =
state->refline;
1655 reference += (
txt -
state->curline);
1657 for (
i = 0;
i <
len;
i++)
1661 if (
ch == (
char) 0xFF)
1687 if (
state->callbacks->get_variable)
1688 value =
state->callbacks->get_variable(varname, quote,
1689 state->cb_passthrough);
1714 if (
state->callbacks->get_variable)
1716 state->cb_passthrough);
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define fprintf(file, fmt, msg)
int PQmblen(const char *s, int encoding)
#define pg_malloc_array(type, count)
#define pg_malloc0_object(type)
#define pg_malloc_object(type)
#define pg_valid_server_encoding_id
int pg_strcasecmp(const char *s1, const char *s2)
unsigned char pg_tolower(unsigned char ch)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
enum _promptStatus promptStatus_t
static void psqlscan_record_initial_keyword(const char *identifier, char *idents, int idents_size, int *idents_count)
YY_BUFFER_STATE psqlscan_prepare_buffer(PsqlScanState state, const char *txt, int len, char **txtcopy)
void psql_scan_get_location(PsqlScanState state, int *lineno, int *offset)
void psql_scan_reset(PsqlScanState state)
void psql_scan_destroy(PsqlScanState state)
static bool psqlscan_is_create_routine(const char *idents)
PsqlScanResult psql_scan(PsqlScanState state, PQExpBuffer query_buf, promptStatus_t *prompt)
PsqlScanState psql_scan_create(const PsqlScanCallbacks *callbacks)
void psql_scan_set_passthrough(PsqlScanState state, void *passthrough)
void psql_scan_setup(PsqlScanState state, const char *line, int line_len, int encoding, bool std_strings)
void psql_scan_reselect_sql_lexer(PsqlScanState state)
bool psql_scan_in_quote(PsqlScanState state)
void psql_scan_finish(PsqlScanState state)
struct yy_buffer_state * YY_BUFFER_STATE