From 9f5b3841584131bfe1647902e71277ac63e726a4 Mon Sep 17 00:00:00 2001 From: jz0 Date: Wed, 11 Aug 2021 16:53:39 +0800 Subject: [PATCH] Fix set stmt view limit pushdown bug. --- .../rewrite/ob_transform_outerjoin_limit_pushdown.cpp | 9 +++++++-- src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.h | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp b/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp index 224294be87..31ec1e96e5 100644 --- a/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp +++ b/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp @@ -405,8 +405,13 @@ int ObTransformOuterJoinLimitPushDown::check_validity_for_target_table(OjLimitPu } else if (has_rownum) { is_valid = false; } else { - // no need to create new view - helper.need_create_view_ = false; + if (ref_query->is_set_stmt()) { + helper.need_create_view_ = true; + } else { + // no need to create new view + helper.need_create_view_ = false; + } + helper.need_rename_ = true; helper.view_table_ = helper.target_table_; } } else { diff --git a/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.h b/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.h index 84591e2b92..bc8904b796 100644 --- a/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.h +++ b/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.h @@ -35,7 +35,8 @@ private: extracted_conditions_(), saved_order_items_(), is_limit_only_(false), - need_create_view_(true) + need_create_view_(true), + need_rename_(false) {} virtual ~OjLimitPushDownHelper(){}; @@ -46,9 +47,10 @@ private: ObSEArray saved_order_items_; bool is_limit_only_; bool need_create_view_; + bool need_rename_; TO_STRING_KV(K_(select_stmt), K_(target_table), K_(view_table), K_(extracted_conditions), K_(saved_order_items), - K_(is_limit_only), K_(need_create_view)); + K_(is_limit_only), K_(need_create_view), K_(need_rename)); }; public: -- GitLab