2014-08-05 10:52:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-10-16 11:02:26 +00:00
|
|
|
#include <DB/Parsers/ASTQueryWithOutput.h>
|
2014-08-05 10:52:06 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2015-10-16 11:02:26 +00:00
|
|
|
struct ASTCheckQuery : public ASTQueryWithOutput
|
2014-08-05 10:52:06 +00:00
|
|
|
{
|
2015-10-16 11:02:26 +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
|
|
|
{
|
2016-05-28 15:42:22 +00:00
|
|
|
return std::make_shared<ASTCheckQuery>(*this);
|
2014-08-05 10:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string database;
|
|
|
|
std::string table;
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(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())
|
|
|
|
{
|
2016-10-15 00:04:58 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(database) << (settings.hilite ? hilite_none : "");
|
2015-08-05 21:38:31 +00:00
|
|
|
settings.ostr << ".";
|
|
|
|
}
|
2016-10-15 00:04:58 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(table) << (settings.hilite ? hilite_none : "");
|
2015-08-05 21:38:31 +00:00
|
|
|
}
|
|
|
|
settings.ostr << nl_or_ws;
|
|
|
|
}
|
2014-08-05 10:52:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|