From 4b1f26e4ebb4f21f7d7baa684b64c7ca173fdc17 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 9 Feb 2023 16:01:02 +0000 Subject: [PATCH] [CP] [to #47499273] fix bulk collect table which may modified by sql --- src/sql/ob_spi.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 8275ce37bc..8604491b84 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -5697,6 +5697,22 @@ int ObSPIService::get_result(ObPLExecCtx *ctx, LOG_WARN("read result error", K(ret)); } } + if (OB_SUCC(ret)) { + for (int64_t i = 0; OB_SUCC(ret) && i < bulk_tables.count(); ++i) { + ObPLCollection *table = bulk_tables.at(i); + CK (OB_NOT_NULL(table)); + if (OB_SUCC(ret) && table->get_count() > 0) { + if (implicit_cursor == NULL || !implicit_cursor->get_in_forall()) { + // only clear table data, do not reset collection allocator, + // because fetch rows already copy to collection allocator, in store_result only do shadow copy. + table->set_count(0); + table->set_first(OB_INVALID_INDEX); + table->set_last(OB_INVALID_INDEX); + table->set_data(NULL); + } + } + } + } if (OB_SUCC(ret) && row_count > 0) { // 累积存储在pl table里 OZ (store_result(bulk_tables, row_count, type_count, tmp_result, NULL == implicit_cursor ? false : implicit_cursor->get_in_forall()));