1 | #include "parseDatabaseAndTableName.h" |
2 | #include <Parsers/ExpressionElementParsers.h> |
3 | #include <Parsers/ASTIdentifier.h> |
4 | #include <Parsers/CommonParsers.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | bool parseDatabaseAndTableName(IParser::Pos & pos, Expected & expected, String & database_str, String & table_str) |
11 | { |
12 | ParserToken s_dot(TokenType::Dot); |
13 | ParserIdentifier table_parser; |
14 | |
15 | ASTPtr database; |
16 | ASTPtr table; |
17 | |
18 | database_str = "" ; |
19 | table_str = "" ; |
20 | |
21 | if (!table_parser.parse(pos, database, expected)) |
22 | return false; |
23 | |
24 | if (s_dot.ignore(pos)) |
25 | { |
26 | if (!table_parser.parse(pos, table, expected)) |
27 | { |
28 | database_str = "" ; |
29 | return false; |
30 | } |
31 | |
32 | tryGetIdentifierNameInto(database, database_str); |
33 | tryGetIdentifierNameInto(table, table_str); |
34 | } |
35 | else |
36 | { |
37 | database_str = "" ; |
38 | tryGetIdentifierNameInto(database, table_str); |
39 | } |
40 | |
41 | return true; |
42 | } |
43 | |
44 | } |
45 | |