diff --git a/src/sql/rewrite/ob_transform_const_propagate.cpp b/src/sql/rewrite/ob_transform_const_propagate.cpp index 24b7ef42f5..cb24ce008c 100644 --- a/src/sql/rewrite/ob_transform_const_propagate.cpp +++ b/src/sql/rewrite/ob_transform_const_propagate.cpp @@ -294,6 +294,21 @@ int ObTransformConstPropagate::do_transform(ObDMLStmt *stmt, } } + if (OB_SUCC(ret) && !const_ctx.active_const_infos_.empty() && + (stmt->is_insert_stmt() || stmt->is_merge_stmt())) { + is_happened = false; + ObDelUpdStmt *insert = static_cast(stmt); + if (OB_FAIL(collect_equal_pair_from_condition(stmt, + insert->get_sharding_conditions(), + const_ctx, + is_happened))) { + LOG_WARN("failed to collect const info from sharding condition", K(ret)); + } else { + trans_happened |= is_happened; + LOG_TRACE("succeed to do const propagation while collect from sharding", K(is_happened)); + } + } + if (OB_SUCC(ret) && !const_ctx.active_const_infos_.empty() && (stmt->is_insert_stmt() || stmt->is_merge_stmt())) { ObDelUpdStmt *insert = static_cast(stmt); diff --git a/src/sql/rewrite/ob_transform_expr_pullup.cpp b/src/sql/rewrite/ob_transform_expr_pullup.cpp index c1962b1680..0460f500ff 100644 --- a/src/sql/rewrite/ob_transform_expr_pullup.cpp +++ b/src/sql/rewrite/ob_transform_expr_pullup.cpp @@ -173,7 +173,7 @@ int ObTransformExprPullup::need_transform(const ObIArray &paren need_trans = false; OPT_TRACE("outline reject transform"); } else { - for (int64_t i = 0; OB_SUCC(ret) && i < stmt.get_table_size(); ++i) { + for (int64_t i = 0; !need_trans && OB_SUCC(ret) && i < stmt.get_table_size(); ++i) { const TableItem *table = NULL; if (OB_ISNULL(table = stmt.get_table_item(i))) { ret = OB_ERR_UNEXPECTED;