2019-06-29 16:58:32 +00:00
|
|
|
#include <iomanip>
|
|
|
|
#include <Parsers/ASTShowTablesQuery.h>
|
2019-10-08 18:42:22 +00:00
|
|
|
#include <Common/quoteString.h>
|
2019-06-29 16:58:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
ASTPtr ASTShowTablesQuery::clone() const
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTShowTablesQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
cloneOutputOptions(*res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-09-15 16:07:27 +00:00
|
|
|
void ASTShowTablesQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
2019-06-29 16:58:32 +00:00
|
|
|
{
|
|
|
|
if (databases)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW DATABASES" << (settings.hilite ? hilite_none : "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-11 13:21:52 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (temporary ? "TEMPORARY " : "") <<
|
|
|
|
(dictionaries ? "DICTIONARIES" : "TABLES") << (settings.hilite ? hilite_none : "");
|
2019-06-29 16:58:32 +00:00
|
|
|
|
|
|
|
if (!from.empty())
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "")
|
|
|
|
<< backQuoteIfNeed(from);
|
|
|
|
|
|
|
|
if (!like.empty())
|
2020-01-31 18:42:08 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << (not_like ? " NOT" : "") << " LIKE " << (settings.hilite ? hilite_none : "")
|
2019-06-29 16:58:32 +00:00
|
|
|
<< std::quoted(like, '\'');
|
2019-09-15 16:07:27 +00:00
|
|
|
|
|
|
|
if (limit_length)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
|
|
|
limit_length->formatImpl(settings, state, frame);
|
|
|
|
}
|
2019-06-29 16:58:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|