From dde384c1699ec187a830ad8ec449a48e41cbb5b9 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 7 Feb 2023 17:09:44 +0800 Subject: [PATCH] fix allocate hash window function bug --- src/sql/optimizer/ob_select_log_plan.cpp | 18 ++++++++---------- src/sql/optimizer/ob_select_log_plan.h | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/sql/optimizer/ob_select_log_plan.cpp b/src/sql/optimizer/ob_select_log_plan.cpp index a738ba9d8f..e5922dbe44 100644 --- a/src/sql/optimizer/ob_select_log_plan.cpp +++ b/src/sql/optimizer/ob_select_log_plan.cpp @@ -4510,7 +4510,7 @@ int ObSelectLogPlan::generate_window_functions_plan(const ObIArray, 8> pby_oby_prefixes, const int64_t start, - const bool not_split, + const int64_t end, const ObIArray &partition_exprs, const int64_t prefix_pos, int64_t &part_cnt) @@ -4612,18 +4612,16 @@ int ObSelectLogPlan::get_partition_count(const ObSEArray 0 || partition_exprs.empty()) { part_cnt = 0; - } else if (not_split) { - part_cnt = pby_oby_prefixes.at(0).first; - for (int64_t i = 1; OB_SUCC(ret) && i < pby_oby_prefixes.count(); ++i) { + } else if (OB_UNLIKELY(start < 0 || end > pby_oby_prefixes.count() || start >= end)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected pby_oby_prefixes count ", K(ret), K(start), K(end), K(pby_oby_prefixes.count())); + } else { + part_cnt = pby_oby_prefixes.at(start).first; + for (int64_t i = start + 1; OB_SUCC(ret) && i < end; ++i) { if (pby_oby_prefixes.at(i).first < part_cnt) { part_cnt = pby_oby_prefixes.at(i).first; } } - } else if (OB_UNLIKELY(start < 0 || start >= pby_oby_prefixes.count())) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("get unexpected pby_oby_prefixes count ", K(ret), K(start), K(pby_oby_prefixes.count())); - } else { - part_cnt = pby_oby_prefixes.at(start).first; } return ret; } diff --git a/src/sql/optimizer/ob_select_log_plan.h b/src/sql/optimizer/ob_select_log_plan.h index 6917d49f16..9076022a06 100644 --- a/src/sql/optimizer/ob_select_log_plan.h +++ b/src/sql/optimizer/ob_select_log_plan.h @@ -531,7 +531,7 @@ private: int get_partition_count(const ObSEArray, 8> pby_oby_prefixes, const int64_t start, - const bool not_split, + const int64_t end, const ObIArray &partition_exprs, const int64_t prefix_pos, int64_t &part_cnt);