mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 09:52:38 +00:00
Add new error code for function that already exists and use while trying create user-defined functions
This commit is contained in:
parent
7f3e5b9166
commit
2643b71393
@ -549,6 +549,7 @@
|
|||||||
M(579, INCORRECT_PART_TYPE) \
|
M(579, INCORRECT_PART_TYPE) \
|
||||||
M(580, CANNOT_SET_ROUNDING_MODE) \
|
M(580, CANNOT_SET_ROUNDING_MODE) \
|
||||||
M(581, TOO_LARGE_DISTRIBUTED_DEPTH) \
|
M(581, TOO_LARGE_DISTRIBUTED_DEPTH) \
|
||||||
|
M(582, FUNCTION_ALREADY_EXISTS) \
|
||||||
\
|
\
|
||||||
M(998, POSTGRESQL_CONNECTION_FAILURE) \
|
M(998, POSTGRESQL_CONNECTION_FAILURE) \
|
||||||
M(999, KEEPER_EXCEPTION) \
|
M(999, KEEPER_EXCEPTION) \
|
||||||
|
@ -22,6 +22,7 @@ namespace ErrorCodes
|
|||||||
{
|
{
|
||||||
extern const int UNKNOWN_FUNCTION;
|
extern const int UNKNOWN_FUNCTION;
|
||||||
extern const int LOGICAL_ERROR;
|
extern const int LOGICAL_ERROR;
|
||||||
|
extern const int FUNCTION_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String & getFunctionCanonicalNameIfAny(const String & name)
|
const String & getFunctionCanonicalNameIfAny(const String & name)
|
||||||
@ -140,6 +141,9 @@ void FunctionFactory::registerUserDefinedFunction(
|
|||||||
const ASTCreateFunctionQuery & create_function_query,
|
const ASTCreateFunctionQuery & create_function_query,
|
||||||
CaseSensitiveness case_sensitiveness)
|
CaseSensitiveness case_sensitiveness)
|
||||||
{
|
{
|
||||||
|
if (hasNameOrAlias(create_function_query.function_name))
|
||||||
|
throw Exception("The function '" + create_function_query.function_name + "' already exists", ErrorCodes::FUNCTION_ALREADY_EXISTS);
|
||||||
|
|
||||||
registerFunction(create_function_query.function_name, [create_function_query](ContextPtr context)
|
registerFunction(create_function_query.function_name, [create_function_query](ContextPtr context)
|
||||||
{
|
{
|
||||||
auto function = UserDefinedFunction::create(context);
|
auto function = UserDefinedFunction::create(context);
|
||||||
|
Loading…
Reference in New Issue
Block a user