mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
70d1adfe4b
* save format string for NetException * format exceptions * format exceptions 2 * format exceptions 3 * format exceptions 4 * format exceptions 5 * format exceptions 6 * fix * format exceptions 7 * format exceptions 8 * Update MergeTreeIndexGin.cpp * Update AggregateFunctionMap.cpp * Update AggregateFunctionMap.cpp * fix
80 lines
2.2 KiB
C++
80 lines
2.2 KiB
C++
#include <Parsers/ASTDropQuery.h>
|
|
#include <Common/quoteString.h>
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int SYNTAX_ERROR;
|
|
}
|
|
|
|
|
|
String ASTDropQuery::getID(char delim) const
|
|
{
|
|
if (kind == ASTDropQuery::Kind::Drop)
|
|
return "DropQuery" + (delim + getDatabase()) + delim + getTable();
|
|
else if (kind == ASTDropQuery::Kind::Detach)
|
|
return "DetachQuery" + (delim + getDatabase()) + delim + getTable();
|
|
else if (kind == ASTDropQuery::Kind::Truncate)
|
|
return "TruncateQuery" + (delim + getDatabase()) + delim + getTable();
|
|
else
|
|
throw Exception(ErrorCodes::SYNTAX_ERROR, "Not supported kind of drop query.");
|
|
}
|
|
|
|
ASTPtr ASTDropQuery::clone() const
|
|
{
|
|
auto res = std::make_shared<ASTDropQuery>(*this);
|
|
cloneOutputOptions(*res);
|
|
cloneTableOptions(*res);
|
|
return res;
|
|
}
|
|
|
|
void ASTDropQuery::formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const
|
|
{
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
|
if (kind == ASTDropQuery::Kind::Drop)
|
|
settings.ostr << "DROP ";
|
|
else if (kind == ASTDropQuery::Kind::Detach)
|
|
settings.ostr << "DETACH ";
|
|
else if (kind == ASTDropQuery::Kind::Truncate)
|
|
settings.ostr << "TRUNCATE ";
|
|
else
|
|
throw Exception(ErrorCodes::SYNTAX_ERROR, "Not supported kind of drop query.");
|
|
|
|
if (temporary)
|
|
settings.ostr << "TEMPORARY ";
|
|
|
|
|
|
if (!table && database)
|
|
settings.ostr << "DATABASE ";
|
|
else if (is_dictionary)
|
|
settings.ostr << "DICTIONARY ";
|
|
else if (is_view)
|
|
settings.ostr << "VIEW ";
|
|
else
|
|
settings.ostr << "TABLE ";
|
|
|
|
if (if_exists)
|
|
settings.ostr << "IF EXISTS ";
|
|
|
|
settings.ostr << (settings.hilite ? hilite_none : "");
|
|
|
|
if (!table && database)
|
|
settings.ostr << backQuoteIfNeed(getDatabase());
|
|
else
|
|
settings.ostr << (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
|
|
formatOnCluster(settings);
|
|
|
|
if (permanently)
|
|
settings.ostr << " PERMANENTLY";
|
|
|
|
if (sync)
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " SYNC" << (settings.hilite ? hilite_none : "");
|
|
}
|
|
|
|
}
|