2012-08-02 19:04:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Core/Field.h>
|
2015-10-12 07:05:54 +00:00
|
|
|
#include <DB/Core/FieldVisitors.h>
|
2012-08-02 19:04:26 +00:00
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/** SET запрос
|
|
|
|
*/
|
|
|
|
class ASTSetQuery : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Change
|
|
|
|
{
|
|
|
|
String name;
|
|
|
|
Field value;
|
|
|
|
};
|
|
|
|
|
2016-05-28 10:35:44 +00:00
|
|
|
using Changes = std::vector<Change>;
|
2012-08-02 19:04:26 +00:00
|
|
|
Changes changes;
|
|
|
|
|
|
|
|
bool global; /// Если запрос SET GLOBAL.
|
|
|
|
|
2014-12-17 15:26:24 +00:00
|
|
|
ASTSetQuery() = default;
|
|
|
|
ASTSetQuery(const StringRange range_) : IAST(range_) {}
|
2015-08-06 03:26:27 +00:00
|
|
|
|
2012-08-02 19:04:26 +00:00
|
|
|
/** Получить текст, который идентифицирует этот элемент. */
|
2015-05-03 09:13:08 +00:00
|
|
|
String getID() const override { return "Set"; };
|
2012-08-02 19:04:26 +00:00
|
|
|
|
2016-05-28 15:42:22 +00:00
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTSetQuery>(*this); }
|
2015-08-06 03:26:27 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SET " << (global ? "GLOBAL " : "") << (settings.hilite ? hilite_none : "");
|
|
|
|
|
|
|
|
for (ASTSetQuery::Changes::const_iterator it = changes.begin(); it != changes.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != changes.begin())
|
|
|
|
settings.ostr << ", ";
|
|
|
|
|
2017-01-06 17:41:19 +00:00
|
|
|
settings.ostr << it->name << " = " << applyVisitor(FieldVisitorToString(), it->value);
|
2015-08-06 03:26:27 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-02 19:04:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|