[CP] [to #2024103100104889553]fix bug, cursor formal param is sys_refcursor with actual param null

This commit is contained in:
obdev 2024-11-20 10:15:03 +00:00 committed by ob-robot
parent b6bca92248
commit d6e2246876
2 changed files with 20 additions and 13 deletions

View File

@ -2910,9 +2910,11 @@ int ObPLExecState::set_var(int64_t var_idx, const ObObjParam& value)
OZ (ObUserDefinedType::destruct_objparam(*get_allocator(), params->at(var_idx), ctx_.exec_ctx_->get_my_session()));
OX (params->at(var_idx).set_extend(0, extend_type, val_len));
}
OZ (ctx_.get_user_type(udt_id, user_type), K(udt_id));
CK (OB_NOT_NULL(user_type));
OZ (init_complex_obj(*get_allocator(), *user_type, params->at(var_idx)));
if (!params->at(var_idx).is_ref_cursor_type()) {
OZ (ctx_.get_user_type(udt_id, user_type), K(udt_id));
CK (OB_NOT_NULL(user_type));
OZ (init_complex_obj(*get_allocator(), *user_type, params->at(var_idx)));
}
} else if (!copy_value.is_ext()) {
bool is_ref_cursor = params->at(var_idx).is_ref_cursor_type();
copy_value.ObObj::set_scale(params->at(var_idx).get_meta().get_scale());
@ -3631,6 +3633,7 @@ int ObPLExecState::init_params(const ParamStore *params, bool is_anonymous)
} else if (func_.get_variables().at(i).is_ref_cursor_type()) {
OX (param.set_is_ref_cursor_type(true));
OX (param.set_extend(0, PL_REF_CURSOR_TYPE));
OX (param.set_udt_id(func_.get_variables().at(i).get_user_type_id()));
// CURSOR初始化为NULL
} else if (func_.get_variables().at(i).is_cursor_type()) {
// leave obj as null type, spi_init wil init it.

View File

@ -8510,6 +8510,8 @@ int ObPLResolver::convert_cursor_actual_params(
convert_expr));
OZ (func.add_expr(convert_expr));
OX (idx = func.get_exprs().count() - 1);
} else if (convert_expr->get_result_type().is_null()) {
//actual params is null, do nothing
} else if (pl_data_type.is_cursor_type()) {
if (convert_expr->get_result_type().get_extend_type() != PL_CURSOR_TYPE
&& convert_expr->get_result_type().get_extend_type() != PL_REF_CURSOR_TYPE) {
@ -8519,18 +8521,20 @@ int ObPLResolver::convert_cursor_actual_params(
K(convert_expr->get_result_type().get_obj_meta().get_type()),
K(pl_data_type.get_user_type_id()),
K(convert_expr->get_result_type().get_udt_id()));
}
}
} else if (!convert_expr->get_result_type().is_ext()) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("PLS-00382: expression is of wrong type",
K(ret), K(pl_data_type.is_obj_type()), KPC(convert_expr),
K(convert_expr->get_result_type().get_obj_meta().get_type()),
K(pl_data_type.get_user_type_id()));
} else if (pl_data_type.get_user_type_id() != convert_expr->get_result_type().get_udt_id()) {
bool is_compatible = false;
if (convert_expr->get_result_type().is_null()) {
is_compatible = true;
} else if (convert_expr->get_result_type().is_ext()) {
CK (OB_NOT_NULL(current_block_));
OZ (check_composite_compatible(current_block_->get_namespace(),
convert_expr->get_result_type().get_udt_id(),
pl_data_type.get_user_type_id(),
is_compatible));
}
CK (OB_NOT_NULL(current_block_));
OZ (check_composite_compatible(current_block_->get_namespace(),
convert_expr->get_result_type().get_udt_id(),
pl_data_type.get_user_type_id(),
is_compatible));
if (OB_SUCC(ret) && !is_compatible) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
LOG_WARN("PLS-00382: expression is of wrong type",