From 7085d9745441324c7eeacbaf1927b00519602740 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 8 Sep 2023 11:46:26 +0800 Subject: [PATCH] to issue<51998150>:fix core when fetch cursor after this cursor has been closed --- src/pl/ob_pl_type.cpp | 23 ++++++++++++++++++++--- src/sql/ob_spi.cpp | 4 +++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pl/ob_pl_type.cpp b/src/pl/ob_pl_type.cpp index fac2f74343..9aa3e56cdc 100644 --- a/src/pl/ob_pl_type.cpp +++ b/src/pl/ob_pl_type.cpp @@ -1990,10 +1990,27 @@ int ObPLCursorInfo::deep_copy(ObPLCursorInfo &src, common::ObIAllocator *allocat } else if (OB_ISNULL(row)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("row is null", K(ret)); - } else if (OB_FAIL(dest_cursor->row_store_.add_row(*row))) { - LOG_WARN("failed to add row to row store", K(ret)); } else { - ++cur; + ObNewRow tmp_row = *row; + for (int64_t i = 0; OB_SUCC(ret) && i < tmp_row.get_count(); ++i) { + ObObj& obj = tmp_row.get_cell(i); + ObObj tmp; + if (obj.is_pl_extend()) { + if (OB_FAIL(pl::ObUserDefinedType::deep_copy_obj(*(dest_cursor->allocator_), obj, tmp))) { + LOG_WARN("failed to copy pl extend", K(ret)); + } else { + obj = tmp; + dest_cursor->complex_objs_.push_back(tmp); + } + } + } + if (OB_SUCC(ret)) { + if (OB_FAIL(dest_cursor->row_store_.add_row(tmp_row))) { + LOG_WARN("failed to add row to row store", K(ret)); + } else { + ++cur; + } + } } } diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index af5157b310..3a2ed52118 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -7294,7 +7294,8 @@ int ObSPIService::convert_obj(ObPLExecCtx *ctx, LOG_DEBUG("column convert", K(obj.get_meta()), K(result_types[i].get_meta_type()), K(current_type.at(i)), K(result_types[i].get_accuracy())); if (obj.is_pl_extend()/* && pl::PL_RECORD_TYPE == obj.get_meta().get_extend_type()*/ - && result_types[i].get_meta_type().is_ext()) { + && result_types[i].get_meta_type().is_ext() + && obj.get_meta().get_extend_type() != PL_CURSOR_TYPE) { //record嵌object场景,object属性在resolver阶段要求强一致,无需强转 OZ (calc_array.push_back(obj)); } else if (obj.get_meta() == result_types[i].get_meta_type() @@ -7435,6 +7436,7 @@ int ObSPIService::store_result(ObPLExecCtx *ctx, 1 == type_count && 1 == obj_array.count() && obj_array.at(0).is_pl_extend() && + obj_array.at(0).get_meta().get_extend_type() != PL_CURSOR_TYPE && obj_array.at(0).get_meta().get_extend_type() != PL_OPAQUE_TYPE); // xmltypes may need to do cast if (!is_schema_object) { if (OB_SUCC(ret) && type_count != obj_array.count()) {