ClickHouse/src/Interpreters/InterpreterDropFunctionQuery.cpp

39 lines
1.2 KiB
C++
Raw Normal View History

#include <Parsers/ASTDropFunctionQuery.h>
2021-07-19 23:34:04 +00:00
#include <Access/ContextAccess.h>
#include <Interpreters/Context.h>
2021-05-14 22:43:04 +00:00
#include <Interpreters/FunctionNameNormalizer.h>
#include <Interpreters/InterpreterDropFunctionQuery.h>
#include <Interpreters/UserDefinedSQLObjectsLoader.h>
#include <Interpreters/UserDefinedSQLFunctionFactory.h>
#include <Interpreters/executeDDLQueryOnCluster.h>
2021-05-14 22:43:04 +00:00
2021-07-19 23:34:04 +00:00
2021-05-14 22:43:04 +00:00
namespace DB
{
BlockIO InterpreterDropFunctionQuery::execute()
{
2021-05-14 22:43:04 +00:00
FunctionNameNormalizer().visit(query_ptr.get());
2021-10-27 15:49:18 +00:00
ASTDropFunctionQuery & drop_function_query = query_ptr->as<ASTDropFunctionQuery &>();
AccessRightsElements access_rights_elements;
access_rights_elements.emplace_back(AccessType::DROP_FUNCTION);
2021-10-27 15:49:18 +00:00
if (!drop_function_query.cluster.empty())
{
DDLQueryOnClusterParams params;
params.access_to_check = std::move(access_rights_elements);
return executeDDLQueryOnCluster(query_ptr, getContext(), params);
}
auto current_context = getContext();
current_context->checkAccess(access_rights_elements);
2021-08-23 14:31:58 +00:00
2021-10-27 15:49:18 +00:00
UserDefinedSQLFunctionFactory::instance().unregisterFunction(current_context, drop_function_query.function_name, drop_function_query.if_exists);
2021-08-18 09:29:52 +00:00
2021-05-14 22:43:04 +00:00
return {};
}
}