1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #ifndef _SQL_SCAN_H_ |
10 | #define _SQL_SCAN_H_ |
11 | |
12 | #include "sql_mem.h" |
13 | #include "sql_list.h" |
14 | #include "stream.h" |
15 | |
16 | typedef enum { LINE_1, LINE_N } prot; |
17 | |
18 | struct scanner { |
19 | bstream *rs; |
20 | stream *ws; |
21 | stream *log; |
22 | |
23 | int yynext; /* next token, lr(1) isn't powerful enough for sql */ |
24 | int yylast; /* previous token, to detect superfluous semi-colons */ |
25 | int yyval; /* current token */ |
26 | size_t yysval; /* start of current token */ |
27 | size_t yycur; /* next char in the queue */ |
28 | size_t as; /* start of query part of view's etc */ |
29 | char yybak; /* sometimes it's needed to write an EOS marker */ |
30 | int key; /* query hash */ |
31 | int started; /* found at least one token */ |
32 | prot mode; /* which mode (line (1,N), blocked) */ |
33 | char *schema; /* Keep schema name of create statement, needed AUTO_INCREMENT, SERIAL */ |
34 | char *errstr; /* error message from the bowels of the scanner */ |
35 | }; |
36 | |
37 | #define QUERY(scanner) (scanner.rs->buf+scanner.rs->pos) |
38 | |
39 | extern char *query_cleaned(const char *query); |
40 | extern void scanner_init(struct scanner *s, bstream *rs, stream *ws); |
41 | extern void scanner_reset_key(struct scanner *s); |
42 | extern void scanner_query_processed(struct scanner *s); |
43 | |
44 | extern int scanner_init_keywords(void); |
45 | #endif /* _SQL_SCAN_H_ */ |
46 | |
47 | |