[to #48216783] fix array access out of range error report

This commit is contained in:
obdev
2023-08-10 11:48:28 +00:00
committed by ob-robot
parent 12edc62dbc
commit 4c7c89c2fd
3 changed files with 8 additions and 5 deletions

View File

@ -4335,6 +4335,7 @@ int ObPLCodeGenerator::generate_get_collection_attr(ObLLVMValue &param_array,
const ObObjAccessIdx &current_access,
int64_t access_i,
bool for_write,
bool is_assoc_array,
ObLLVMValue &current_value,
ObLLVMValue &ret_value_ptr,
ObLLVMBasicBlock& exit)
@ -4352,7 +4353,7 @@ int ObPLCodeGenerator::generate_get_collection_attr(ObLLVMValue &param_array,
OZ (helper_.create_icmp(is_inited, not_init_value, ObLLVMHelper::ICMP_EQ, not_init));
OZ (helper_.create_cond_br(not_init, not_init_block, after_init_block));
OZ (helper_.set_insert_point(not_init_block));
OZ (helper_.get_int32(OB_NOT_INIT, ret_value));
OZ (helper_.get_int32(OB_ERR_COLLECION_NULL, ret_value));
OZ (helper_.create_store(ret_value, ret_value_ptr));
OZ (helper_.create_br(exit));
OZ (helper_.set_insert_point(after_init_block));
@ -4435,7 +4436,7 @@ int ObPLCodeGenerator::generate_get_collection_attr(ObLLVMValue &param_array,
OZ (helper_.create_icmp(high, element_idx, ObLLVMHelper::ICMP_SGT, is_true));
OZ (helper_.create_cond_br(is_true, after_block, error_block));
OZ (helper_.set_insert_point(error_block));
OZ (helper_.get_int32(OB_ARRAY_OUT_OF_RANGE, ret_value));
OZ (helper_.get_int32(is_assoc_array ? OB_READ_NOTHING : OB_ERR_SUBSCRIPT_OUTSIDE_LIMIT, ret_value));
OZ (helper_.create_store(ret_value, ret_value_ptr));
OZ (helper_.create_br(exit));
OZ (helper_.set_insert_point(after_block));
@ -4572,6 +4573,7 @@ int ObPLCodeGenerator::generate_get_attr(ObLLVMValue &param_array,
obj_access.at(i),
i,
for_write,
parent_type.is_associative_array_type(),
value,
ret_value_ptr,
exit));

View File

@ -657,6 +657,7 @@ private:
const ObObjAccessIdx &current_access,
int64_t access_i,
bool for_write,
bool is_assoc_array,
jit::ObLLVMValue &current_value,
jit::ObLLVMValue &ret_value_ptr,
jit::ObLLVMBasicBlock& exit);

View File

@ -233,8 +233,8 @@ int ObExprObjAccess::ExtraInfo::get_collection_attr(int64_t* params,
int64_t element_idx;
CK (OB_NOT_NULL(current_coll));
if (OB_SUCC(ret) && !current_coll->is_inited()) {
ret = OB_NOT_INIT;
LOG_WARN("", K(ret), KPC(current_coll));
ret = OB_ERR_COLLECION_NULL;
LOG_WARN("Reference to uninitialized collection", K(ret), KPC(current_coll));
}
if (OB_SUCC(ret) && !current_access.is_property()) {
if (current_access.is_const()) {
@ -383,7 +383,7 @@ int ObExprObjAccess::ExtraInfo::calc(ObObj &result,
OZ (get_attr_func(param_array.count(), param_ptr, &attr_addr, *ctx));
}
if (OB_FAIL(ret)) {
if (OB_NOT_INIT == ret && pl::ObCollectionType::EXISTS_PROPERTY == property_type_) {
if (OB_ERR_COLLECION_NULL == ret && pl::ObCollectionType::EXISTS_PROPERTY == property_type_) {
ret = OB_SUCCESS;
result.set_tinyint(0);
}