diff --git a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp index 6b4d240ac..0e4acc102 100644 --- a/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp +++ b/deps/oblib/src/lib/mysqlclient/ob_mysql_prepared_statement.cpp @@ -2336,6 +2336,7 @@ int ObMySQLProcStatement::process_array_out_param(const pl::ObCollectionType *co OZ (pl::ObUserDefinedType::destruct_obj(param, nullptr, true)); CK (OB_NOT_NULL(coll = reinterpret_cast(param.get_ext()))); OX (coll->set_count(0)); + LOG_INFO("coll allocator is", K(coll->get_allocator()), K(ret)); } else { // 原来无值,重新分配内存 int64_t init_size = 0; @@ -2442,7 +2443,10 @@ int ObMySQLProcStatement::process_array_out_param(const pl::ObCollectionType *co coll->set_last(array_size); } else if (NULL != new_data) { for (int64_t j = 0; j < i; j++) { - pl::ObUserDefinedType::destruct_objparam(*local_allocator, new_data[j]); + int tmp_ret = OB_SUCCESS; + if (OB_SUCCESS != (tmp_ret = pl::ObUserDefinedType::destruct_objparam(*local_allocator, new_data[j]))) { + LOG_WARN("dblink destruct_objparam failed", K(ret), K(tmp_ret)); + } } local_allocator->free(new_data); } @@ -2492,27 +2496,32 @@ int ObMySQLProcStatement::process_array_out_param(const pl::ObCollectionType *co ObObj *element = NULL; new(ptr)pl::ObPLRecord(record_type->get_user_type_id(), record_type->get_member_count()); OZ (record->init_data(*local_allocator, false)); - CK (record->get_allocator()); - for (int64_t j = 0; OB_SUCC(ret) && j < record_type->get_member_count(); ++j) { - CK (OB_NOT_NULL(record_type->get_record_member_type(j))); - OZ (record->get_element(j, element)); - CK (OB_NOT_NULL(element)); - CK (record_type->get_record_member_type(j)->is_obj_type()); - OX (new (element) ObObj(ObNullType)); - if (OB_SUCC(ret)) { - CK (start_idx + j < com_data.get_data_array().count()); - CK (OB_NOT_NULL(bind_param = com_data.get_data_array().at(start_idx + j))); - CK (MYSQL_TYPE_OBJECT == bind_param->buffer_type_); - CK (OB_NOT_NULL(pl_array = (MYSQL_COMPLEX_BIND_ARRAY *)bind_param->buffer_)); - OX (element->set_meta_type(*(record_type->get_record_member_type(j)->get_meta_type()))); - OZ (process_array_element(i, *(record->get_allocator()), pl_array->buffer, *element, tz_info)); - } - } // end for - } - if (NULL != ptr) { - current_obj->set_extend(reinterpret_cast(ptr), pl::PL_RECORD_TYPE, init_size); if (OB_FAIL(ret)) { - pl::ObUserDefinedType::destruct_objparam(*local_allocator, *current_obj); + local_allocator->free(ptr); + } else { + CK (record->get_allocator()); + for (int64_t j = 0; OB_SUCC(ret) && j < record_type->get_member_count(); ++j) { + CK (OB_NOT_NULL(record_type->get_record_member_type(j))); + OZ (record->get_element(j, element)); + CK (OB_NOT_NULL(element)); + CK (record_type->get_record_member_type(j)->is_obj_type()); + OX (new (element) ObObj(ObNullType)); + if (OB_SUCC(ret)) { + CK (start_idx + j < com_data.get_data_array().count()); + CK (OB_NOT_NULL(bind_param = com_data.get_data_array().at(start_idx + j))); + CK (MYSQL_TYPE_OBJECT == bind_param->buffer_type_); + CK (OB_NOT_NULL(pl_array = (MYSQL_COMPLEX_BIND_ARRAY *)bind_param->buffer_)); + OX (element->set_meta_type(*(record_type->get_record_member_type(j)->get_meta_type()))); + OZ (process_array_element(i, *(record->get_allocator()), pl_array->buffer, *element, tz_info)); + } + } // end for + current_obj->set_extend(reinterpret_cast(ptr), pl::PL_RECORD_TYPE, init_size); + if (OB_FAIL(ret)) { + int tmp_ret = OB_SUCCESS; + if (OB_SUCCESS != (tmp_ret = pl::ObUserDefinedType::destruct_objparam(*local_allocator, *current_obj))) { + LOG_WARN("dblink destruct_objparam failed", K(ret), K(tmp_ret)); + } + } } } } @@ -2524,7 +2533,10 @@ int ObMySQLProcStatement::process_array_out_param(const pl::ObCollectionType *co coll->set_last(array_size); } else if (NULL != new_data) { for (int64_t j = 0; j < i; j++) { - pl::ObUserDefinedType::destruct_objparam(*local_allocator, new_data[j]); + int tmp_ret = OB_SUCCESS; + if (OB_SUCCESS != (tmp_ret = pl::ObUserDefinedType::destruct_objparam(*local_allocator, new_data[j]))) { + LOG_WARN("dblink destruct_objparam failed", K(ret), K(tmp_ret)); + } } local_allocator->free(new_data); } diff --git a/src/pl/ob_pl_user_type.cpp b/src/pl/ob_pl_user_type.cpp index 9dd3849b3..3e0ce898d 100644 --- a/src/pl/ob_pl_user_type.cpp +++ b/src/pl/ob_pl_user_type.cpp @@ -283,7 +283,7 @@ int ObUserDefinedType::destruct_objparam(ObIAllocator &alloc, ObObj &src, ObSQLS ObPLComposite *composite = reinterpret_cast(src.get_ext()); if (direct_use_alloc) { ObIAllocator *allocator = nullptr; - CK (OB_NOT_NULL(composite)); + OV (OB_NOT_NULL(composite), OB_ERR_UNEXPECTED, lbt()); OX (allocator = composite->get_allocator()); OZ (SMART_CALL(ObUserDefinedType::destruct_obj(src, session))); if (OB_SUCC(ret) && OB_NOT_NULL(allocator)) { @@ -292,8 +292,8 @@ int ObUserDefinedType::destruct_objparam(ObIAllocator &alloc, ObObj &src, ObSQLS } OX (alloc.free(composite)); } else { - CK (OB_NOT_NULL(composite)); - CK (OB_NOT_NULL(composite->get_allocator())); + OV (OB_NOT_NULL(composite), OB_ERR_UNEXPECTED, lbt()); + OV (OB_NOT_NULL(composite->get_allocator()), OB_ERR_UNEXPECTED, lbt()); OX (pl_allocator = dynamic_cast(composite->get_allocator())); CK (OB_NOT_NULL(pl_allocator)); CK (OB_NOT_NULL(parent_allocator = pl_allocator->get_parent_allocator())); diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 9349bbd9e..f7c7cf8c2 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -9075,7 +9075,7 @@ int ObSPIService::spi_execute_dblink(ObExecContext &exec_ctx, if (exec_params.at(i).is_pl_extend()) { int tmp_ret = OB_SUCCESS; if (OB_SUCCESS != (tmp_ret = ObUserDefinedType::destruct_obj(exec_params.at(i)))) { - LOG_WARN("destruct obj failed", K(ret), K(exec_params.at(i))); + LOG_WARN("destruct obj failed", K(ret), K(tmp_ret), K(exec_params.at(i))); } } } @@ -9083,7 +9083,7 @@ int ObSPIService::spi_execute_dblink(ObExecContext &exec_ctx, && ob_is_extend(routine_info->get_ret_type()->get_obj_type())) { int tmp_ret = OB_SUCCESS; if (OB_SUCCESS != (tmp_ret = ObUserDefinedType::destruct_obj(tmp_result))) { - LOG_WARN("destruct obj failed", K(ret), K(tmp_result)); + LOG_WARN("destruct obj failed", K(ret), K(tmp_ret), K(tmp_result)); } } if (OB_SUCC(ret) && NULL != result && !result->is_null() && result->is_ext()) {