1#include <iomanip>
2#include <Parsers/ASTShowTablesQuery.h>
3#include <Common/quoteString.h>
4
5
6namespace DB
7{
8
9ASTPtr ASTShowTablesQuery::clone() const
10{
11 auto res = std::make_shared<ASTShowTablesQuery>(*this);
12 res->children.clear();
13 cloneOutputOptions(*res);
14 return res;
15}
16
17void ASTShowTablesQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
18{
19 if (databases)
20 {
21 settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW DATABASES" << (settings.hilite ? hilite_none : "");
22 }
23 else
24 {
25 settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (temporary ? "TEMPORARY " : "") <<
26 (dictionaries ? "DICTIONARIES" : "TABLES") << (settings.hilite ? hilite_none : "");
27
28 if (!from.empty())
29 settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "")
30 << backQuoteIfNeed(from);
31
32 if (!like.empty())
33 settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIKE " << (settings.hilite ? hilite_none : "")
34 << std::quoted(like, '\'');
35
36 if (limit_length)
37 {
38 settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
39 limit_length->formatImpl(settings, state, frame);
40 }
41 }
42}
43
44}
45