1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <Parsers/ParserDeleteQuery.h>
#include <Parsers/ASTDeleteQuery.h>
#include <Parsers/parseDatabaseAndTableName.h>
#include <Parsers/ExpressionListParsers.h>
#include <Parsers/ParserSetQuery.h>
namespace DB
{
bool ParserDeleteQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
auto query = std::make_shared<ASTDeleteQuery>();
node = query;
ParserKeyword s_delete("DELETE");
ParserKeyword s_from("FROM");
ParserKeyword s_where("WHERE");
ParserExpression parser_exp_elem;
ParserKeyword s_settings("SETTINGS");
ParserKeyword s_on{"ON"};
if (s_delete.ignore(pos, expected))
{
if (!s_from.ignore(pos, expected))
return false;
if (!parseDatabaseAndTableAsAST(pos, expected, query->database, query->table))
return false;
if (s_on.ignore(pos, expected))
{
String cluster_str;
if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
return false;
query->cluster = cluster_str;
}
if (!s_where.ignore(pos, expected))
return false;
if (!parser_exp_elem.parse(pos, query->predicate, expected))
return false;
if (s_settings.ignore(pos, expected))
{
ParserSetQuery parser_settings(true);
if (!parser_settings.parse(pos, query->settings_ast, expected))
return false;
}
}
else
return false;
if (query->predicate)
query->children.push_back(query->predicate);
if (query->database)
query->children.push_back(query->database);
if (query->table)
query->children.push_back(query->table);
if (query->settings_ast)
query->children.push_back(query->settings_ast);
return true;
}
}
|