diff --git a/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp b/src/sql/rewrite/ob_transform_outerjoin_limit_pushdown.cpp index 224294be8774d5e74dc417c056397beb65d7e96a..31ec1e96e546ecdece5871a73e65b7a4db8ada6c 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 84591e2b92e07b0e442c4abaa544df252609d546..bc8904b796d5d9788da92889168a1bd948805658 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: