diff --git a/src/sql/printer/ob_select_stmt_printer.cpp b/src/sql/printer/ob_select_stmt_printer.cpp index b94845b91f..4cf09df465 100644 --- a/src/sql/printer/ob_select_stmt_printer.cpp +++ b/src/sql/printer/ob_select_stmt_printer.cpp @@ -59,7 +59,7 @@ int ObSelectStmtPrinter::do_print() LOG_WARN("fail to print_unpivot", KPC(stmt_->get_transpose_item()), K(ret)); } - } else if (OB_FAIL(print())) { + } else if (OB_FAIL(SMART_CALL(print()))) { LOG_WARN("fail to print stmt", KPC(stmt_), K(ret)); } } diff --git a/src/sql/resolver/dml/ob_dml_stmt.cpp b/src/sql/resolver/dml/ob_dml_stmt.cpp index 4a4d836da2..d7aa70b06f 100644 --- a/src/sql/resolver/dml/ob_dml_stmt.cpp +++ b/src/sql/resolver/dml/ob_dml_stmt.cpp @@ -4538,7 +4538,7 @@ int ObDMLStmt::disable_writing_external_table(bool basic_stmt_is_dml /* defualt } else if (schema::EXTERNAL_TABLE == table_item->table_type_) { disable_write_table = true; } else if (table_item->is_view_table_ && NULL != table_item->ref_query_) { - OZ( table_item->ref_query_->disable_writing_external_table(true) ); + OZ( SMART_CALL(table_item->ref_query_->disable_writing_external_table(true)) ); } } } @@ -4551,7 +4551,7 @@ int ObDMLStmt::disable_writing_external_table(bool basic_stmt_is_dml /* defualt LOG_WARN("failed to get stmt's child_stmts", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < child_stmts.count(); ++i) { - OZ( child_stmts.at(i)->disable_writing_external_table() ); + OZ( SMART_CALL(child_stmts.at(i)->disable_writing_external_table()) ); } } } diff --git a/src/sql/resolver/expr/ob_raw_expr.cpp b/src/sql/resolver/expr/ob_raw_expr.cpp index edd7addf5d..bc0999de0e 100644 --- a/src/sql/resolver/expr/ob_raw_expr.cpp +++ b/src/sql/resolver/expr/ob_raw_expr.cpp @@ -1609,7 +1609,9 @@ bool ObQueryRefRawExpr::inner_same_as( bool bool_ret = false; if (get_expr_type() == expr.get_expr_type()) { const ObQueryRefRawExpr &u_expr = static_cast(expr); - if (check_context != NULL && check_context->override_query_compare_) { + if (is_set_ != u_expr.is_set_ || is_multiset_ != u_expr.is_multiset_) { + /* bool bool_ret = false; */ + } else if (check_context != NULL && check_context->override_query_compare_) { bool_ret = check_context->compare_query(*this, u_expr); } else { // very tricky, check the definition of ref_stmt_ and get_ref_stmt() @@ -2356,6 +2358,27 @@ void ObOpRawExpr::clear_child() exprs_.reset(); } +int ObOpRawExpr::get_subquery_comparison_flag() const +{ + enum { + INVALID = 0, // not subquery comparison + NONE = 1, + ALL = 2, + ANY = 3 + } comparison_flag; + comparison_flag = INVALID; + if (IS_SUBQUERY_COMPARISON_OP(get_expr_type())) { + if (has_flag(IS_WITH_ALL)) { + comparison_flag = ALL; + } else if (has_flag(IS_WITH_ANY)) { + comparison_flag = ANY; + } else { + comparison_flag = NONE; + } + } + return comparison_flag; +} + bool ObOpRawExpr::inner_same_as( const ObRawExpr &expr, ObExprEqualCheckContext *check_context) const @@ -2393,6 +2416,12 @@ bool ObOpRawExpr::inner_same_as( } else { need_cmp = false; } + } else if (IS_SUBQUERY_COMPARISON_OP(get_expr_type())) { + const ObOpRawExpr &tmp = static_cast(expr); + if (tmp.get_expr_type() != get_expr_type() || + tmp.get_subquery_comparison_flag() != get_subquery_comparison_flag()) { + need_cmp = false; + } } else if (expr.get_expr_type() != get_expr_type()) { need_cmp = false; } diff --git a/src/sql/resolver/expr/ob_raw_expr.h b/src/sql/resolver/expr/ob_raw_expr.h index a215efb3ad..0869a408a6 100644 --- a/src/sql/resolver/expr/ob_raw_expr.h +++ b/src/sql/resolver/expr/ob_raw_expr.h @@ -2958,6 +2958,7 @@ public: int64_t &pos, ExplainType type) const; bool is_white_runtime_filter_expr() const override; + int get_subquery_comparison_flag() const; VIRTUAL_TO_STRING_KV_CHECK_STACK_OVERFLOW(N_ITEM_TYPE, type_, N_RESULT_TYPE, result_type_, N_EXPR_INFO, info_, diff --git a/src/sql/rewrite/ob_transform_simplify_expr.cpp b/src/sql/rewrite/ob_transform_simplify_expr.cpp index 53bef87aa7..c7cb98393e 100644 --- a/src/sql/rewrite/ob_transform_simplify_expr.cpp +++ b/src/sql/rewrite/ob_transform_simplify_expr.cpp @@ -2856,10 +2856,14 @@ int ObTransformSimplifyExpr::remove_duplicate_exprs(ObQueryCtx* query_ctx, LOG_WARN("failed to do remove duplicate exprs", K(ret)); } else if (param_conds.count() == conditions.count()) { //do nothing - } else if (OB_FAIL(conditions.assign(param_conds))) { - LOG_WARN("assign array failed", K(ret)); } else { - trans_happened = true; + OPT_TRACE("before remove duplicate exprs", conditions); + OPT_TRACE("after duplicate exprs happened", param_conds); + if (OB_FAIL(conditions.assign(param_conds))) { + LOG_WARN("assign array failed", K(ret)); + } else { + trans_happened = true; + } } } if (OB_SUCC(ret) && trans_happened) { @@ -2929,8 +2933,15 @@ int ObTransformSimplifyExpr::do_remove_duplicate_exprs(ObQueryCtx &query_ctx, ObStmtCompareContext cmp_ctx; cmp_ctx.init(&query_ctx.calculable_items_); for (int64_t i = param_count - 1; OB_SUCC(ret) && i >= 1; i--) { + if (OB_ISNULL(exprs.at(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpect null pointer error"); + } for (int64_t j = 0; OB_SUCC(ret) && j < i; j++) { - if (exprs.at(i)->same_as(*exprs.at(j), &cmp_ctx)) { + if (OB_ISNULL(exprs.at(j))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpect null pointer error"); + } else if (exprs.at(i)->same_as(*exprs.at(j), &cmp_ctx)) { if (OB_FAIL(exprs.remove(i))) { LOG_WARN("failed to remove", K(ret)); } else if (!cmp_ctx.equal_param_info_.empty()) {