diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index ad44e4d2d..adbcb9151 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -2136,7 +2136,7 @@ int ObPLExecState::init_complex_obj(ObIAllocator &allocator, CK (OB_NOT_NULL(schema_guard = ctx_.exec_ctx_->get_sql_ctx()->schema_guard_)); CK (OB_NOT_NULL(sql_proxy = ctx_.exec_ctx_->get_sql_proxy())); CK (OB_NOT_NULL(package_guard = ctx_.exec_ctx_->get_package_guard())); - if (pl_type.is_ref_cursor_type()) { + if (pl_type.is_ref_cursor_type() || pl_type.is_sys_refcursor_type()) { OX (obj.set_is_ref_cursor_type(true)); } else if (pl_type.is_udt_type()) { ObPLUDTNS ns(*schema_guard); @@ -2149,19 +2149,11 @@ int ObPLExecState::init_complex_obj(ObIAllocator &allocator, *sql_proxy, false); OZ (ns.init_complex_obj(allocator, pl_type, obj, false)); - } else if (pl_type.is_sys_refcursor_type()) { - OX (obj.set_is_ref_cursor_type(true)); - // ObPLCursorInfo *cursor = NULL; - // if (obj.is_null()) { - // OZ (session->make_cursor(cursor)); - // OX (obj.set_ext(reinterpret_cast(cursor))); - // OX (obj.set_param_meta()); - // } else { - // cursor = reinterpret_cast(obj.get_ext()); - // int64_t id = cursor->get_id(); //已经分配好的SYS REFCURSOR,关闭语句后id需要保留 - // OZ (cursor->close(*session)); - // OX (cursor->set_id(id)); - // } + } else if (OB_NOT_NULL(session->get_pl_context()) + && OB_NOT_NULL(session->get_pl_context()->get_current_ctx())) { + pl::ObPLINS *ns = session->get_pl_context()->get_current_ctx(); + CK (OB_NOT_NULL(ns)); + OZ (ns->init_complex_obj(allocator, pl_type, obj, false)); } OX (obj.set_udt_id(pl_type.get_user_type_id())); return ret; @@ -2414,7 +2406,9 @@ do { \ OZ (init_complex_obj( (*get_allocator()), func_.get_variables().at(i), get_params().at(i))); } - } else if (pl_type.is_composite_type() && params->at(i).is_null()) { + } else if (pl_type.is_composite_type() + && (params->at(i).is_null() + || (params->at(i).is_ext() && params->at(i).get_ext() == 0))) { // 如果复杂类型传入了null则构造一个初始化的值 OZ (init_complex_obj((*get_allocator()), func_.get_variables().at(i), diff --git a/src/pl/ob_pl_code_generator.cpp b/src/pl/ob_pl_code_generator.cpp index 5f18621b9..0da158592 100644 --- a/src/pl/ob_pl_code_generator.cpp +++ b/src/pl/ob_pl_code_generator.cpp @@ -4199,7 +4199,7 @@ int ObPLCodeGenerator::generate_get_collection_attr(ObLLVMValue ¶m_array, element_idx, current_value)); - if (OB_SUCC(ret) && !for_write) { + if (OB_SUCC(ret)) { // check deleted value ObLLVMValue p_type_value; ObLLVMValue type_value; @@ -4211,9 +4211,19 @@ int ObPLCodeGenerator::generate_get_collection_attr(ObLLVMValue ¶m_array, OZ (helper_.create_icmp_eq(type_value, ObMaxType, is_deleted)); OZ (helper_.create_cond_br(is_deleted, delete_block, after_delete_block)); OZ (helper_.set_insert_point(delete_block)); - OZ (helper_.get_int32(OB_READ_NOTHING, ret_value)); - OZ (helper_.create_store(ret_value, ret_value_ptr)); - OZ (helper_.create_br(exit)); + if (!for_write) { + OZ (helper_.get_int32(OB_READ_NOTHING, ret_value)); + OZ (helper_.create_store(ret_value, ret_value_ptr)); + OZ (helper_.create_br(exit)); + } else { + if (current_access.var_type_.is_composite_type()) { + OZ (helper_.get_int8(ObExtendType, type_value)); + } else { + OZ (helper_.get_int8(current_access.var_type_.get_obj_type(), type_value)); + } + OZ (helper_.create_store(type_value, p_type_value)); + OZ (helper_.create_br(after_delete_block)); + } OZ (helper_.set_insert_point(after_delete_block)); } } else {