2012-08-02 19:04:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-11-24 13:55:31 +00:00
|
|
|
#include <Common/FieldVisitors.h>
|
2019-04-18 23:29:32 +00:00
|
|
|
#include <Common/SettingsChanges.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2012-08-02 19:04:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** SET query
|
2012-08-02 19:04:26 +00:00
|
|
|
*/
|
|
|
|
class ASTSetQuery : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2017-09-17 18:49:43 +00:00
|
|
|
bool is_standalone = true; /// If false, this AST is a part of another query, such as SELECT.
|
|
|
|
|
2019-04-18 23:29:32 +00:00
|
|
|
SettingsChanges changes;
|
2012-08-02 19:04:26 +00:00
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override { return "Set"; }
|
2012-08-02 19:04:26 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTSetQuery>(*this); }
|
2015-08-06 03:26:27 +00:00
|
|
|
|
2017-12-01 18:36:55 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-09-17 18:49:43 +00:00
|
|
|
if (is_standalone)
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SET " << (settings.hilite ? hilite_none : "");
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2019-04-18 23:29:32 +00:00
|
|
|
for (auto it = changes.begin(); it != changes.end(); ++it)
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
if (it != changes.begin())
|
|
|
|
settings.ostr << ", ";
|
|
|
|
|
|
|
|
settings.ostr << it->name << " = " << applyVisitor(FieldVisitorToString(), it->value);
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 19:04:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|