PostgreSQL Source Code: src/include/fe_utils/psqlscan.h File Reference (original) (raw)
Go to the source code of this file.
Typedefs | |
---|---|
typedef struct PsqlScanStateData * | PsqlScanState |
typedef enum _promptStatus | promptStatus_t |
typedef struct PsqlScanCallbacks | PsqlScanCallbacks |
Enumerations | |
---|---|
enum | PsqlScanResult { PSCAN_SEMICOLON, PSCAN_BACKSLASH, PSCAN_INCOMPLETE, PSCAN_EOL } |
enum | _promptStatus { PROMPT_READY, PROMPT_CONTINUE, PROMPT_COMMENT, PROMPT_SINGLEQUOTE, PROMPT_DOUBLEQUOTE, PROMPT_DOLLARQUOTE, PROMPT_PAREN, PROMPT_COPY } |
enum | PsqlScanQuoteType { PQUOTE_PLAIN, PQUOTE_SQL_LITERAL, PQUOTE_SQL_IDENT, PQUOTE_SHELL_ARG } |
Functions | |
---|---|
PsqlScanState | psql_scan_create (const PsqlScanCallbacks *callbacks) |
void | psql_scan_destroy (PsqlScanState state) |
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_finish (PsqlScanState state) |
PsqlScanResult | psql_scan (PsqlScanState state, PQExpBuffer query_buf, promptStatus_t *prompt) |
void | psql_scan_reset (PsqlScanState state) |
void | psql_scan_reselect_sql_lexer (PsqlScanState state) |
bool | psql_scan_in_quote (PsqlScanState state) |
void | psql_scan_get_location (PsqlScanState state, int *lineno, int *offset) |
◆ promptStatus_t
◆ PsqlScanCallbacks
◆ PsqlScanState
◆ _promptStatus
Enumerator |
---|
PROMPT_READY |
PROMPT_CONTINUE |
PROMPT_COMMENT |
PROMPT_SINGLEQUOTE |
PROMPT_DOUBLEQUOTE |
PROMPT_DOLLARQUOTE |
PROMPT_PAREN |
PROMPT_COPY |
Definition at line 39 of file psqlscan.h.
40{
enum _promptStatus promptStatus_t
◆ PsqlScanQuoteType
Enumerator |
---|
PQUOTE_PLAIN |
PQUOTE_SQL_LITERAL |
PQUOTE_SQL_IDENT |
PQUOTE_SHELL_ARG |
Definition at line 52 of file psqlscan.h.
◆ PsqlScanResult
Enumerator |
---|
PSCAN_SEMICOLON |
PSCAN_BACKSLASH |
PSCAN_INCOMPLETE |
PSCAN_EOL |
Definition at line 30 of file psqlscan.h.
◆ psql_scan()
Definition at line 1121 of file psqlscan.l.
1124{
1126 int lexresult;
1127
1128
1130
1131
1132 state->output_buf = query_buf;
1133
1134
1135 if (state->buffer_stack != NULL)
1136 yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
1137 else
1138 yy_switch_to_buffer(state->scanbufhandle, state->scanner);
1139
1140
1141 lexresult = yylex(NULL, state->scanner);
1142
1143
1144 if (state->cur_line_no == 0)
1145 state->cur_line_no = 1;
1146
1147
1148
1149
1150 switch (lexresult)
1151 {
1153 switch (state->start_state)
1154 {
1155 case INITIAL:
1156 case xqs:
1157 if (state->paren_depth > 0)
1158 {
1161 }
1162 else if (state->begin_depth > 0)
1163 {
1166 }
1167 else if (query_buf->len > 0)
1168 {
1171 }
1172 else
1173 {
1174
1177 }
1178 break;
1179 case xb:
1182 break;
1183 case xc:
1186 break;
1187 case xd:
1190 break;
1191 case xh:
1194 break;
1195 case xe:
1198 break;
1199 case xq:
1202 break;
1203 case xdolq:
1206 break;
1207 case xui:
1210 break;
1211 case xus:
1214 break;
1215 default:
1216
1217 fprintf(stderr, "invalid YY_START\n");
1218 exit(1);
1219 }
1220 break;
1224 break;
1228 break;
1229 default:
1230
1231 fprintf(stderr, "invalid yylex result\n");
1232 exit(1);
1233 }
1234
1235 return result;
1236}
#define fprintf(file, fmt, msg)
Assert(PointerIsAligned(start, uint64))
int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner)
References Assert(), fprintf, PQExpBufferData::len, LEXRES_BACKSLASH, LEXRES_EOL, LEXRES_SEMI, PROMPT_COMMENT, PROMPT_CONTINUE, PROMPT_DOLLARQUOTE, PROMPT_DOUBLEQUOTE, PROMPT_PAREN, PROMPT_READY, PROMPT_SINGLEQUOTE, PSCAN_BACKSLASH, PSCAN_EOL, PSCAN_INCOMPLETE, PSCAN_SEMICOLON, and yylex().
Referenced by MainLoop(), ParseScript(), and test_psql_parse().
◆ psql_scan_create()
◆ psql_scan_destroy()
◆ psql_scan_finish()
◆ psql_scan_get_location()
void psql_scan_get_location | ( | PsqlScanState | state, |
---|---|---|---|
int * | lineno, | ||
int * | offset | ||
) |
Definition at line 1335 of file psqlscan.l.
1337{
1338 const char *line_end;
1339
1340
1341
1342
1343
1344
1345 if (state->cur_line_no == 0)
1346 {
1347 *lineno = 1;
1348 *offset = 0;
1349 return;
1350 }
1351
1352
1353
1354
1355
1356 while ((line_end = strchr(state->cur_line_ptr, '\n')) != NULL)
1357 {
1358 state->cur_line_no++;
1359 state->cur_line_ptr = line_end + 1;
1360 }
1361 state->cur_line_ptr += strlen(state->cur_line_ptr);
1362
1363
1364 *lineno = state->cur_line_no;
1365 *offset = state->cur_line_ptr - state->scanbuf;
1366}
Referenced by expr_lex_one_word(), expr_yyerror_more(), and ParseScript().
◆ psql_scan_in_quote()
◆ psql_scan_reselect_sql_lexer()
◆ psql_scan_reset()
◆ psql_scan_set_passthrough()
void psql_scan_set_passthrough | ( | PsqlScanState | state, |
---|---|---|---|
void * | passthrough | ||
) |
◆ psql_scan_setup()
void psql_scan_setup | ( | PsqlScanState | state, |
---|---|---|---|
const char * | line, | ||
int | line_len, | ||
int | encoding, | ||
bool | std_strings | ||
) |