ClickHouse/dbms/include/DB/Parsers/ASTCheckQuery.h

49 lines
1.4 KiB
C++
Raw Normal View History

2014-08-05 10:52:06 +00:00
#pragma once
#include <DB/Parsers/ASTQueryWithOutput.h>
2014-08-05 10:52:06 +00:00
namespace DB
{
struct ASTCheckQuery : public ASTQueryWithOutput
2014-08-05 10:52:06 +00:00
{
ASTCheckQuery(StringRange range_ = StringRange()) : ASTQueryWithOutput(range_) {};
2014-08-05 10:52:06 +00:00
/** Получить текст, который идентифицирует этот элемент. */
2014-12-17 15:26:24 +00:00
String getID() const override { return ("CheckQuery_" + database + "_" + table); };
2014-08-05 10:52:06 +00:00
2014-12-17 15:26:24 +00:00
ASTPtr clone() const override
2014-08-05 10:52:06 +00:00
{
auto res = std::make_shared<ASTCheckQuery>(*this);
res->children.clear();
cloneOutputOptions(*res);
return res;
2014-08-05 10:52:06 +00:00
}
std::string database;
std::string table;
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{
std::string nl_or_nothing = settings.one_line ? "" : "\n";
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
std::string nl_or_ws = settings.one_line ? " " : "\n";
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "CHECK TABLE " << (settings.hilite ? hilite_none : "");
if (!table.empty())
{
if (!database.empty())
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(database) << (settings.hilite ? hilite_none : "");
settings.ostr << ".";
}
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(table) << (settings.hilite ? hilite_none : "");
}
}
2014-08-05 10:52:06 +00:00
};
}