[to #50868149] fix self attribute access resolve
This commit is contained in:
parent
85cfc17505
commit
7977b8cc58
@ -2650,16 +2650,34 @@ int ObPLExecState::check_routine_param_legal(ParamStore *params)
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("incorrect argument type, expected complex, but get basic type", K(ret));
|
||||
}
|
||||
} else if (NULL == reinterpret_cast<const ObPLComposite *>(params->at(i).get_ext())) {
|
||||
} else if (0 == params->at(i).get_ext()
|
||||
|| ((PL_REF_CURSOR_TYPE == params->at(i).get_meta().get_extend_type()
|
||||
|| PL_CURSOR_TYPE == params->at(i).get_meta().get_extend_type())
|
||||
&& dest_type.is_cursor_type())) {
|
||||
// do nothing
|
||||
} else {
|
||||
const pl::ObPLComposite *src_composite = NULL;
|
||||
uint64_t udt_id = params->at(i).get_udt_id();
|
||||
CK (OB_NOT_NULL(src_composite = reinterpret_cast<const ObPLComposite *>(params->at(i).get_ext())));
|
||||
OV (params->at(i).is_pl_extend(), OB_ERR_UNEXPECTED, K(params->at(i)), K(i));
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (!dest_type.is_composite_type()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("incorrect argument type", K(ret), K(dest_type), K(udt_id));
|
||||
LOG_WARN("incorrect argument type", K(ret));
|
||||
} else if (OB_INVALID_ID == udt_id) {
|
||||
if (PL_RECORD_TYPE == params->at(i).get_meta().get_extend_type()
|
||||
|| PL_NESTED_TABLE_TYPE == params->at(i).get_meta().get_extend_type()
|
||||
|| PL_ASSOCIATIVE_ARRAY_TYPE == params->at(i).get_meta().get_extend_type()
|
||||
|| PL_VARRAY_TYPE == params->at(i).get_meta().get_extend_type()) {
|
||||
const ObPLComposite *composite = reinterpret_cast<const ObPLComposite *>(params->at(i).get_ext());
|
||||
CK (OB_NOT_NULL(composite));
|
||||
OV (udt_id = composite->get_id(), OB_ERR_UNEXPECTED, KPC(composite), K(params->at(i)), K(i));
|
||||
} else if (PL_OPAQUE_TYPE == params->at(i).get_meta().get_extend_type()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("opaque type without udtid is unexpected", K(ret), K(params->at(i)), K(i));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_INVALID_ID == udt_id) { // 匿名数组
|
||||
bool need_cast = false;
|
||||
const pl::ObPLCollection *src_coll = NULL;
|
||||
|
@ -130,12 +130,17 @@ int ObPLCodeGenerateVisitor::visit(const ObPLStmtBlock &s)
|
||||
}
|
||||
}
|
||||
} else if (NULL != exit.get_v()) { //如果没有eh,调到BLOCK自己的exit分支
|
||||
if (OB_FAIL(generator_.get_helper().create_br(exit))) {
|
||||
if (NULL == generator_.get_current().get_v()) {
|
||||
// do nothing...
|
||||
} else if (OB_FAIL(generator_.get_helper().create_br(exit))) {
|
||||
LOG_WARN("failed to create br", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(generator_.set_current(exit))) {
|
||||
LOG_WARN("failed to set current", K(ret));
|
||||
} else { /*do nothing*/ }
|
||||
} else { /*do nothing*/ }
|
||||
|
||||
if (OB_SUCC(ret) && NULL != exit.get_v()) {
|
||||
if (OB_FAIL(generator_.reset_label())) {
|
||||
LOG_WARN("failed to reset label", K(ret));
|
||||
|
@ -12360,6 +12360,7 @@ int ObPLResolver::resolve_access_ident(ObObjAccessIdent &access_ident, // 当前
|
||||
|| (ObPLExternalNS::UDT_NS == type && is_routine)) {
|
||||
OZ (resolve_construct(access_ident, ns, access_idxs, var_index, func));
|
||||
} else if (ObPLExternalNS::INVALID_VAR == type
|
||||
|| (ObPLExternalNS::SELF_ATTRIBUTE == type)
|
||||
|| (ObPLExternalNS::LOCAL_VAR == type && is_routine)
|
||||
|| (ObPLExternalNS::TABLE_NS == type && is_routine)
|
||||
|| (ObPLExternalNS::LABEL_NS == type && is_routine)
|
||||
@ -14822,9 +14823,9 @@ int ObPLResolver::verify_goto_stmt_restriction(const ObPLStmt &goto_stmt,
|
||||
bool is_hit = false;
|
||||
// tracking back to parent recursively,
|
||||
// to see if this goto stmt is transfer control to other encolsing block
|
||||
const ObPLStmtBlock * parent = blk->get_block();
|
||||
const ObPLStmtBlock *parent = blk->get_block();
|
||||
while (OB_NOT_NULL(parent)) {
|
||||
if (parent->is_contain_stmt(&dst_stmt)) {
|
||||
if (parent->is_contain_stmt(&dst_stmt) && !parent->in_handler()) {
|
||||
is_hit = true;
|
||||
break;
|
||||
}
|
||||
@ -14838,8 +14839,11 @@ int ObPLResolver::verify_goto_stmt_restriction(const ObPLStmt &goto_stmt,
|
||||
result = RESTRICTION_JUMP_OUT_EXCEPTION;
|
||||
}
|
||||
} else {
|
||||
// do nothing ...
|
||||
}
|
||||
} else {}
|
||||
} else {
|
||||
// do nothing ...
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2457,6 +2457,38 @@ int ObPLBlockNS::resolve_symbol(const ObString &var_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
// try attribute of self argument
|
||||
if (OB_SUCC(ret)
|
||||
&& OB_NOT_NULL(symbol_table_->get_self_param())
|
||||
&& OB_INVALID_INDEX == var_idx
|
||||
&& OB_INVALID_INDEX == parent_id) {
|
||||
const ObPLDataType &pl_type = symbol_table_->get_self_param()->get_type();
|
||||
const ObUserDefinedType *user_type = NULL;
|
||||
const ObRecordType *record_type = NULL;
|
||||
if (!pl_type.is_udt_type() || pl_type.is_opaque_type()) {
|
||||
// type is invalid when create udt & opaque type has not attribute, so do nothing ...
|
||||
} else if (OB_FAIL(get_user_type(pl_type.get_user_type_id(), user_type))) {
|
||||
LOG_WARN("failed to get user type", K(ret), KPC(user_type));
|
||||
} else if (OB_ISNULL(user_type) || !user_type->is_object_type()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected user type", K(ret), KPC(user_type));
|
||||
} else if (OB_ISNULL(record_type = static_cast<const ObRecordType*>(user_type))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected record type", K(ret), KPC(record_type), KPC(user_type));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < record_type->get_record_member_count(); ++i) {
|
||||
if (OB_ISNULL(record_type->get_record_member_name(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected record member name", K(ret), K(i), KPC(record_type));
|
||||
} else if (ObCharset::case_compat_mode_equal(var_name, *record_type->get_record_member_name(i))) {
|
||||
type = ObPLExternalNS::SELF_ATTRIBUTE;
|
||||
var_idx = i;
|
||||
parent_id = user_type->get_user_type_id();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 尝试解析为外部符号
|
||||
if (OB_SUCC(ret) && OB_INVALID_INDEX == var_idx && resolve_external) {
|
||||
if (OB_NOT_NULL(external_ns_)) {
|
||||
|
@ -1128,6 +1128,7 @@ public:
|
||||
UDF_NS,
|
||||
LOCAL_TYPE, // 本地的自定义类型
|
||||
PKG_TYPE, // 包中的自定义类型
|
||||
SELF_ATTRIBUTE,
|
||||
};
|
||||
|
||||
ObPLExternalNS(const ObPLResolveCtx &resolve_ctx, const ObPLBlockNS *parent_ns)
|
||||
|
@ -129,7 +129,15 @@ int ObCallProcedureExecutor::execute(ObExecContext &ctx, ObCallProcedureStmt &st
|
||||
if (expr->get_is_pl_mock_default_expr()) {
|
||||
param.set_is_pl_mock_default_param(true);
|
||||
}
|
||||
if (ob_is_xml_sql_type(param.get_type(), param.get_udt_subschema_id())) {
|
||||
if (param.is_pl_extend()) {
|
||||
const ObExprOperator *op = expr->get_expr_items().at(0).get_expr_operator();
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr operator", K(ret));
|
||||
} else {
|
||||
param.set_udt_id(op->get_result_type().get_expr_udt_id());
|
||||
}
|
||||
} else if (ob_is_xml_sql_type(param.get_type(), param.get_udt_subschema_id())) {
|
||||
// convert call procedure input sql udt types to pl extend (only xmltype supported currently)
|
||||
bool is_strict = is_strict_mode(ctx.get_my_session()->get_sql_mode());
|
||||
const ObDataTypeCastParams dtc_params =
|
||||
|
@ -213,39 +213,7 @@ int ObCallProcedureResolver::resolve_param_exprs(const ParseNode *params_node,
|
||||
CK (OB_NOT_NULL(params_.session_info_));
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < params_node->num_child_; ++i) {
|
||||
ObRawExpr* raw_expr = NULL;
|
||||
CK (OB_NOT_NULL(params_node->children_[i]));
|
||||
if (OB_SUCC(ret) && params_.is_execute_call_stmt_) {
|
||||
ObArray<ObQualifiedName> columns;
|
||||
ObArray<ObVarInfo> sys_vars;
|
||||
ObArray<ObAggFunRawExpr*> aggr_exprs;
|
||||
ObArray<ObWinFunRawExpr*> win_exprs;
|
||||
ObArray<ObSubQueryInfo> sub_query_info;
|
||||
ObArray<ObUDFInfo> udf_info;
|
||||
ObArray<ObOpRawExpr*> op_exprs;
|
||||
if (OB_FAIL(ObRawExprUtils::build_raw_expr(*params_.expr_factory_,
|
||||
*params_.session_info_,
|
||||
params_.schema_checker_,
|
||||
params_.secondary_namespace_,
|
||||
T_PL_SCOPE,
|
||||
NULL/*ObStmt*/,
|
||||
params_.param_list_,
|
||||
NULL/*external_param_info*/,
|
||||
*params_node->children_[i],
|
||||
raw_expr,
|
||||
columns,
|
||||
sys_vars,
|
||||
aggr_exprs,
|
||||
win_exprs,
|
||||
sub_query_info,
|
||||
udf_info,
|
||||
op_exprs,
|
||||
true,
|
||||
static_cast<TgTimingEvent>(params_.tg_timing_event_)))) {
|
||||
LOG_WARN("failed to build raw expr", K(ret));
|
||||
}
|
||||
} else {
|
||||
OZ (pl::ObPLResolver::resolve_raw_expr(*params_node->children_[i], params_, raw_expr));
|
||||
}
|
||||
OZ (pl::ObPLResolver::resolve_raw_expr(*params_node->children_[i], params_, raw_expr));
|
||||
CK (OB_NOT_NULL(raw_expr));
|
||||
OZ (check_param_expr_legal(raw_expr));
|
||||
OZ (expr_params.push_back(raw_expr));
|
||||
|
Loading…
x
Reference in New Issue
Block a user