ClickHouse/src/Interpreters/InterpreterDropNamedCollectionQuery.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
948 B
C++
Raw Normal View History

#include <Interpreters/InterpreterDropNamedCollectionQuery.h>
#include <Parsers/ASTDropNamedCollectionQuery.h>
#include <Access/ContextAccess.h>
#include <Interpreters/Context.h>
#include <Interpreters/executeDDLQueryOnCluster.h>
#include <Common/NamedCollections/NamedCollectionUtils.h>
namespace DB
{
BlockIO InterpreterDropNamedCollectionQuery::execute()
{
auto current_context = getContext();
current_context->checkAccess(AccessType::DROP_NAMED_COLLECTION);
const auto & query = query_ptr->as<const ASTDropNamedCollectionQuery &>();
if (!query.cluster.empty())
{
DDLQueryOnClusterParams params;
return executeDDLQueryOnCluster(query_ptr, current_context, params);
}
if (query.if_exists)
2022-11-15 14:49:25 +00:00
NamedCollectionUtils::removeIfExistsFromSQL(query.collection_name, current_context);
else
2022-11-15 14:49:25 +00:00
NamedCollectionUtils::removeFromSQL(query.collection_name, current_context);
return {};
}
}