[to #49439164] fix opaque constructor function resolve

This commit is contained in:
obdev 2023-05-09 17:59:33 +00:00 committed by ob-robot
parent 44824c8521
commit c1413102b0

View File

@ -9660,11 +9660,9 @@ int ObPLResolver::resolve_object_construct(const sql::ObQualifiedName &q_name,
ObRawExpr *&expr)
{
int ret = OB_SUCCESS;
const ObRecordType *object_type = NULL;
uint64_t type_id = OB_INVALID_ID;
bool is_sys_type = false;
CK (OB_NOT_NULL(object_type = static_cast<const ObRecordType *>(user_type)));
OX (type_id = object_type->get_user_type_id());
OX (type_id = user_type->get_user_type_id());
OX (is_sys_type = (OB_SYS_TENANT_ID == get_tenant_id_by_object_id(type_id)));
if (OB_SUCC(ret)) {
ObUDFInfo &uinfo = const_cast<ObUDFInfo &>(udf_info);
@ -9696,13 +9694,17 @@ int ObPLResolver::resolve_object_construct(const sql::ObQualifiedName &q_name,
// on the other side: object(a number, constructor(a number) constructor object(a varchar));
// resolve_udf will pick the right one, we dont need to resolve record_construct.
// if pick routine not pick default construct, here pick agin. what if we add mock default construct to pick routine logic.
bool use_default_cons = is_sys_type ? (user_type->is_opaque_type() ? false : true) : false;
if (OB_SUCC(ret) && !uinfo.is_udt_overload_default_cons() && !use_default_cons) {
// must have same attribute and param, exclude self param
if (udf_info.ref_expr_->get_param_exprs().count() -1 == object_type->get_member_count()) {
use_default_cons = true;
bool use_buildin_default_constructor = is_sys_type ? (user_type->is_opaque_type() ? false : true) : false;
if (OB_SUCC(ret)
&& !uinfo.is_udt_overload_default_cons()
&& !is_sys_type
&& !user_type->is_opaque_type()) { // opaque type has no member, do not check
const ObRecordType *object_type = NULL;
CK (OB_NOT_NULL(object_type = dynamic_cast<const ObRecordType *>(user_type)));
// must have same attribute and param, exclude self param
if (udf_info.ref_expr_->get_param_exprs().count() - 1 == object_type->get_member_count()) {
use_buildin_default_constructor = true;
for (int64_t i = 1; OB_SUCC(ret) && i < udf_info.ref_expr_->get_param_exprs().count(); ++i) {
const ObRawExpr *param_expr = udf_info.ref_expr_->get_param_exprs().at(i);
@ -9717,7 +9719,7 @@ int ObPLResolver::resolve_object_construct(const sql::ObQualifiedName &q_name,
&& (param_res_type.get_type() == pl_type->get_meta_type()->get_type())) {
// do nothing
} else {
use_default_cons = false;
use_buildin_default_constructor = false;
break;
}
}
@ -9726,7 +9728,7 @@ int ObPLResolver::resolve_object_construct(const sql::ObQualifiedName &q_name,
}
OX (expr = udf_info.ref_expr_);
// if cant find user define construtor, try default construct
if ((OB_SUCCESS == ret && use_default_cons)
if ((OB_SUCCESS == ret && use_buildin_default_constructor)
|| OB_ERR_SP_WRONG_ARG_NUM == ret
|| OB_ERR_FUNCTION_UNKNOWN == ret
|| OB_ERR_SP_UNDECLARED_VAR == ret