2014-08-05 10:52:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-18 15:03:14 +00:00
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
2019-07-03 16:00:24 +00:00
|
|
|
#include <Parsers/ASTPartition.h>
|
2019-07-08 19:55:54 +00:00
|
|
|
|
2014-08-05 10:52:06 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-10-18 15:03:14 +00:00
|
|
|
struct ASTCheckQuery : public ASTQueryWithTableAndOutput
|
2014-08-05 10:52:06 +00:00
|
|
|
{
|
2019-07-03 13:17:19 +00:00
|
|
|
|
|
|
|
ASTPtr partition;
|
|
|
|
|
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 delim) const override { return "CheckQuery" + (delim + database) + delim + table; }
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTCheckQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
cloneOutputOptions(*res);
|
|
|
|
return res;
|
|
|
|
}
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2015-08-05 21:38:31 +00:00
|
|
|
protected:
|
2019-07-03 16:00:24 +00:00
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
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 : "");
|
|
|
|
}
|
2019-07-03 16:00:24 +00:00
|
|
|
|
|
|
|
if (partition)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << " PARTITION " << (settings.hilite ? hilite_none : "");
|
|
|
|
partition->formatImpl(settings, state, frame);
|
|
|
|
}
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-08-05 10:52:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|