| 1 | #pragma once |
| 2 | |
| 3 | #include <Parsers/IParser.h> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | /// Parse query or set 'out_error_message'. |
| 10 | ASTPtr tryParseQuery( |
| 11 | IParser & parser, |
| 12 | const char * & pos, /// Moved to end of parsed fragment. |
| 13 | const char * end, |
| 14 | std::string & out_error_message, |
| 15 | bool hilite, |
| 16 | const std::string & description, |
| 17 | bool allow_multi_statements, /// If false, check for non-space characters after semicolon and set error message if any. |
| 18 | size_t max_query_size); /// If (end - pos) > max_query_size and query is longer than max_query_size then throws "Max query size exceeded". |
| 19 | /// Disabled if zero. Is used in order to check query size if buffer can contains data for INSERT query. |
| 20 | |
| 21 | |
| 22 | /// Parse query or throw an exception with error message. |
| 23 | ASTPtr parseQueryAndMovePosition( |
| 24 | IParser & parser, |
| 25 | const char * & pos, /// Moved to end of parsed fragment. |
| 26 | const char * end, |
| 27 | const std::string & description, |
| 28 | bool allow_multi_statements, |
| 29 | size_t max_query_size); |
| 30 | |
| 31 | |
| 32 | ASTPtr parseQuery( |
| 33 | IParser & parser, |
| 34 | const char * begin, |
| 35 | const char * end, |
| 36 | const std::string & description, |
| 37 | size_t max_query_size); |
| 38 | |
| 39 | ASTPtr parseQuery( |
| 40 | IParser & parser, |
| 41 | const std::string & query, |
| 42 | const std::string & query_description, |
| 43 | size_t max_query_size); |
| 44 | |
| 45 | ASTPtr parseQuery( |
| 46 | IParser & parser, |
| 47 | const std::string & query, |
| 48 | size_t max_query_size); |
| 49 | |
| 50 | |
| 51 | /** Split queries separated by ; on to list of single queries |
| 52 | * Returns pointer to the end of last successfully parsed query (first), and true if all queries are successfully parsed (second) |
| 53 | * NOTE: INSERT's data should be placed in single line. |
| 54 | */ |
| 55 | std::pair<const char *, bool> splitMultipartQuery(const std::string & queries, std::vector<std::string> & queries_list); |
| 56 | |
| 57 | } |
| 58 | |