2023-03-26 14:36:38 +00:00
|
|
|
#include <Parsers/ASTShowColumnsQuery.h>
|
|
|
|
|
|
|
|
#include <iomanip>
|
|
|
|
#include <Common/quoteString.h>
|
|
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
ASTPtr ASTShowColumnsQuery::clone() const
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTShowColumnsQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
cloneOutputOptions(*res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTShowColumnsQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
|
|
|
<< "SHOW "
|
|
|
|
<< (extended ? "EXTENDED " : "")
|
|
|
|
<< (full ? "FULL " : "")
|
|
|
|
<< "COLUMNS"
|
|
|
|
<< (settings.hilite ? hilite_none : "");
|
|
|
|
|
2023-05-02 12:14:17 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "") << backQuoteIfNeed(table);
|
|
|
|
if (!database.empty())
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "") << backQuoteIfNeed(database);
|
2023-03-26 14:36:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (!like.empty())
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
2023-03-31 13:53:52 +00:00
|
|
|
<< (not_like ? " NOT" : "")
|
2023-03-28 21:01:17 +00:00
|
|
|
<< (case_insensitive_like ? " ILIKE " : " LIKE")
|
2023-03-26 14:36:38 +00:00
|
|
|
<< (settings.hilite ? hilite_none : "")
|
|
|
|
<< DB::quote << like;
|
|
|
|
|
|
|
|
if (where_expression)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WHERE " << (settings.hilite ? hilite_none : "");
|
|
|
|
where_expression->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limit_length)
|
|
|
|
{
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
|
|
|
limit_length->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|