1#pragma once
2
3#include <Common/FieldVisitors.h>
4#include <Common/SettingsChanges.h>
5#include <Parsers/IAST.h>
6
7
8namespace DB
9{
10
11
12/** SET query
13 */
14class ASTSetQuery : public IAST
15{
16public:
17 bool is_standalone = true; /// If false, this AST is a part of another query, such as SELECT.
18
19 SettingsChanges changes;
20
21 /** Get the text that identifies this element. */
22 String getID(char) const override { return "Set"; }
23
24 ASTPtr clone() const override { return std::make_shared<ASTSetQuery>(*this); }
25
26 void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
27 {
28 if (is_standalone)
29 settings.ostr << (settings.hilite ? hilite_keyword : "") << "SET " << (settings.hilite ? hilite_none : "");
30
31 for (auto it = changes.begin(); it != changes.end(); ++it)
32 {
33 if (it != changes.begin())
34 settings.ostr << ", ";
35
36 settings.ostr << it->name << " = " << applyVisitor(FieldVisitorToString(), it->value);
37 }
38 }
39};
40
41}
42