forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathASTCreateHandlerQuery.cpp
More file actions
82 lines (70 loc) · 1.94 KB
/
Copy pathASTCreateHandlerQuery.cpp
File metadata and controls
82 lines (70 loc) · 1.94 KB
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
72
73
74
75
76
77
78
79
80
81
82
#include <Parsers/ASTCreateHandlerQuery.h>
#include <Common/quoteString.h>
#include <IO/Operators.h>
#include <Poco/String.h>
namespace DB
{
ASTPtr ASTCreateHandlerQuery::clone() const
{
auto res = make_intrusive<ASTCreateHandlerQuery>(*this);
res->children.clear();
if (query)
{
res->query = query->clone();
res->children.push_back(res->query);
}
return res;
}
void ASTCreateHandlerQuery::formatImpl(WriteBuffer & ostr, const IAST::FormatSettings & settings, IAST::FormatState & state, IAST::FormatStateStacked frame) const
{
ostr << (is_alter ? "ALTER HANDLER " : "CREATE HANDLER ");
if (if_not_exists)
ostr << "IF NOT EXISTS ";
ostr << backQuoteIfNeed(handler_name);
formatOnCluster(ostr, settings);
if (protocol)
{
/// A protocol literally named "any" must be back-quoted, otherwise it would be parsed back
/// as the PROTOCOL ANY reset clause.
if (Poco::icompare(*protocol, "any") == 0)
ostr << " PROTOCOL " << backQuote(*protocol);
else
ostr << " PROTOCOL " << backQuoteIfNeed(*protocol);
}
else if (reset_protocol)
{
ostr << " PROTOCOL ANY";
}
if (has_url)
{
ostr << " URL ";
switch (url_match_type)
{
case URLMatchType::Exact: break;
case URLMatchType::Prefix: ostr << "PREFIX "; break;
case URLMatchType::Regexp: ostr << "REGEXP "; break;
}
ostr << quoteString(url);
}
if (methods)
{
ostr << " METHODS (";
bool first = true;
for (const auto & method : *methods)
{
if (!first)
ostr << ", ";
first = false;
ostr << method;
}
ostr << ")";
}
if (handler_type)
ostr << " TYPE " << *handler_type;
if (query)
{
ostr << " AS ";
query->format(ostr, settings, state, frame);
}
}
}