From b844359b7fd4af69dc2462a4670f20527797f49a Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 23 Feb 2024 07:49:00 +0000 Subject: [PATCH] [to #52886704] fix udf parameter is enum or set --- src/sql/engine/expr/ob_expr_udf.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_udf.cpp b/src/sql/engine/expr/ob_expr_udf.cpp index d911869c68..e7394218d7 100644 --- a/src/sql/engine/expr/ob_expr_udf.cpp +++ b/src/sql/engine/expr/ob_expr_udf.cpp @@ -130,6 +130,10 @@ int ObExprUDF::calc_result_typeN(ObExprResType &type, } else { types[i].set_calc_collation_type(type_ctx.get_session()->get_nls_collation()); } + } else if (types[i].is_enum_or_set()) { + types[i].set_type(ObVarcharType); + types[i].set_collation_level(params_type_.at(i).get_collation_level()); + types[i].set_collation_type(params_type_.at(i).get_collation_type()); } } } @@ -180,8 +184,12 @@ int ObExprUDF::check_types(const ObExpr &expr, const ObExprUDFInfo &info) if (!expr.args_[i]->obj_meta_.is_null() && (!info.params_desc_.at(i).is_out())) { if (expr.args_[i]->obj_meta_.get_type() != info.params_type_.at(i).get_type()) { - ret = OB_INVALID_ARGUMENT; - LOG_WARN("check param type failed", K(ret), K(i)); + if (info.params_type_.at(i).is_enum_or_set() && ObVarcharType == expr.args_[i]->obj_meta_.get_type()) { + // do nothing ... + } else { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("check param type failed", K(ret), K(i)); + } } } }