58#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
static int backtick_start_offset
static int unquoted_option_chars
static char * option_quote
static enum slash_option_type option_type
static void evaluate_backtick(PsqlScanState state)
68%option never-interactive
74%option prefix="slash_yy"
80%option extra-type="PsqlScanState"
106xeoctesc [\\][0-7]{1,3}
107xehexesc [\\]x[0-9A-Fa-f]{1,2}
108xqdouble {quote}{quote}
110variable_char [A-Za-z\200-\377_0-9]
118 PsqlScanState cur_state =
yyextra;
119 PQExpBuffer output_buf = cur_state->output_buf;
128 BEGIN(cur_state->start_state);
147 cur_state->start_state = YY_START;
169 BEGIN(xslashwholeline);
206 cur_state->start_state = YY_START;
220 BEGIN(xslashbackquote);
232 if (cur_state->callbacks->get_variable == NULL)
242 value = cur_state->callbacks->get_variable(varname,
244 cur_state->cb_passthrough);
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
char * psqlscan_extract_substring(PsqlScanState state, const char *txt, int len)
void psqlscan_escape_variable(PsqlScanState state, const char *txt, int len, PsqlScanQuoteType quote)
275:\"{variable_char}+\" {
282:\{\?{variable_char}+\} {
void psqlscan_test_variable(PsqlScanState state, const char *txt, int len)
300:\{\?{variable_char}* {
327{quote} { BEGIN(xslasharg); }
void appendPQExpBufferChar(PQExpBuffer str, char ch)
340 (
char) strtol(yytext + 1, NULL, 8));
346 (
char) strtol(yytext + 2, NULL, 16));
void psqlscan_emit(PsqlScanState state, const char *txt, int len)
363 if (cur_state->cb_passthrough == NULL ||
bool conditional_active(ConditionalStack cstack)
371 if (cur_state->callbacks->get_variable == NULL)
381 value = cur_state->callbacks->get_variable(varname,
383 cur_state->cb_passthrough);
428 if (output_buf->len > 0)
440 cur_state->start_state = YY_START;
446 cur_state->start_state = YY_START;
453 if (cur_state->buffer_stack == NULL)
455 cur_state->start_state = YY_START;
void psqlscan_select_top_buffer(PsqlScanState state)
void psqlscan_pop_buffer_stack(PsqlScanState state)
491 state->output_buf = &mybuf;
494 if (
state->buffer_stack != NULL)
495 yy_switch_to_buffer(
state->buffer_stack->buf,
state->scanner);
497 yy_switch_to_buffer(
state->scanbufhandle,
state->scanner);
503 state->start_state = xslashcmd;
553 quote = &local_quote;
565 state->output_buf = &mybuf;
568 if (
state->buffer_stack != NULL)
569 yy_switch_to_buffer(
state->buffer_stack->buf,
state->scanner);
571 yy_switch_to_buffer(
state->scanbufhandle,
state->scanner);
575 state->start_state = xslashwholeline;
577 state->start_state = xslashargstart;
583 final_state =
state->start_state;
609 mybuf.
data[mybuf.
len - 1] ==
';')
611 mybuf.
data[--mybuf.
len] =
'\0';
625 mybuf.
len = strlen(mybuf.
data);
629 case xslashbackquote:
635 case xslashwholeline:
645 while (mybuf.
len > 0 &&
646 (mybuf.
data[mybuf.
len - 1] ==
';' ||
647 (isascii((
unsigned char) mybuf.
data[mybuf.
len - 1]) &&
648 isspace((
unsigned char) mybuf.
data[mybuf.
len - 1]))))
650 mybuf.
data[--mybuf.
len] =
'\0';
656 fprintf(stderr,
"invalid YY_START\n");
664 if (mybuf.
len == 0 && *quote == 0)
684 state->output_buf = NULL;
687 if (
state->buffer_stack != NULL)
688 yy_switch_to_buffer(
state->buffer_stack->buf,
state->scanner);
690 yy_switch_to_buffer(
state->scanbufhandle,
state->scanner);
693 state->start_state = xslashend;
713 return state->paren_depth;
723 state->paren_depth = depth;
745 bool inquotes =
false;
752 if (inquotes && cp[1] ==
'"')
758 inquotes = !inquotes;
760 memmove(cp, cp + 1, strlen(cp));
765 if (downcase && !inquotes)
793 fd = popen(cmd,
"r");
805 result = fread(
buf, 1,
sizeof(
buf),
fd);
823 exit_code = pclose(
fd);
839 output_buf->
data[output_buf->
len] =
'\0';
845 if (cmd_output.
len > 0 &&
846 cmd_output.
data[cmd_output.
len - 1] ==
'\n')
void SetShellResultVariables(int wait_result)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define fprintf(file, fmt, msg)
int PQmblenBounded(const char *s, int encoding)
static void const char fflush(stdout)
#define pg_log_error(...)
unsigned char pg_tolower(unsigned char ch)
void initPQExpBuffer(PQExpBuffer str)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void termPQExpBuffer(PQExpBuffer str)
#define PQExpBufferDataBroken(buf)
static int fd(const char *x, int i)
void psql_scan_reselect_sql_lexer(PsqlScanState state)
void psql_scan_slash_command_end(PsqlScanState state)
void psql_scan_set_paren_depth(PsqlScanState state, int depth)
void dequote_downcase_identifier(char *str, bool downcase, int encoding)
int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner)
char * psql_scan_slash_option(PsqlScanState state, enum slash_option_type type, char *quote, bool semicolon)
int psql_scan_get_paren_depth(PsqlScanState state)
char * psql_scan_slash_command(PsqlScanState state)