From bf7035b688d453995a6b5e40947322e3bc52053b Mon Sep 17 00:00:00 2001 From: zzg19950727 <1071026277@qq.com> Date: Wed, 10 May 2023 13:45:59 +0000 Subject: [PATCH] fix some bug --- src/sql/monitor/ob_sql_plan.cpp | 2 ++ src/sql/optimizer/ob_log_join.cpp | 17 +++++++++++++++++ src/sql/optimizer/ob_log_plan.cpp | 3 --- .../optimizer/r/mysql/union_sort_opt.result | 17 +++++++---------- .../static_engine/r/mysql/table_insert.result | 3 +-- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/sql/monitor/ob_sql_plan.cpp b/src/sql/monitor/ob_sql_plan.cpp index 01c90adc48..24e2c82abf 100644 --- a/src/sql/monitor/ob_sql_plan.cpp +++ b/src/sql/monitor/ob_sql_plan.cpp @@ -1910,6 +1910,8 @@ int ObSqlPlan::format_one_output_expr(char *buf, if (0 == print_len && need_new_line) { if (OB_FAIL(BUF_PRINTF(NEW_LINE))) { } else if (OB_FAIL(BUF_PRINTF(OUTPUT_PREFIX))) { + } else { + line_begin_pos = pos; } } if (OB_FAIL(ret)) { diff --git a/src/sql/optimizer/ob_log_join.cpp b/src/sql/optimizer/ob_log_join.cpp index 561b41ea81..3790f59880 100644 --- a/src/sql/optimizer/ob_log_join.cpp +++ b/src/sql/optimizer/ob_log_join.cpp @@ -789,12 +789,29 @@ int ObLogJoin::print_join_tables_in_hint(const ObDMLStmt &stmt, bool is_first_table = true; const ObIArray &table_items = stmt.get_table_items(); const TableItem *table = NULL; + ObSEArray join_tables; for (int64_t i = 0; OB_SUCC(ret) && i < table_items.count(); ++i) { if (OB_ISNULL(table = table_items.at(i))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected null", K(ret), K(table)); } else if (!table_set.has_member(stmt.get_table_bit_index(table->table_id_))) { /* do nothing */ + } else if (OB_FAIL(join_tables.push_back(table))) { + LOG_WARN("failed to push back table", K(ret)); + } + } + auto cmp_func = [](const TableItem *lhs, const TableItem *rhs) { + if (NULL != lhs && NULL != rhs) { + return lhs->get_table_name().compare(rhs->get_table_name()) > 0; + } else { + return false; + } + }; + std::sort(join_tables.begin(), join_tables.end(), cmp_func); + for (int64_t i = 0; OB_SUCC(ret) && i < join_tables.count(); ++i) { + if (OB_ISNULL(table = join_tables.at(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret), K(table)); } else if (!is_first_table && OB_FAIL(BUF_PRINTF(" "))) { } else if (OB_FAIL(print_outline_table(plan_text, table))) { LOG_WARN("fail to print join table", K(ret)); diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index 5ce7e6afb3..c8cb485ab7 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -999,9 +999,6 @@ int ObLogPlan::pre_process_quals(SemiInfo* semi_info) } else if (OB_ISNULL(expr)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected NULL", K(ret), K(expr)); - } else if (expr->has_flag(CNT_ROWNUM) || expr->has_flag(CNT_RAND_FUNC)) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("unexpected expr in semi condition", K(ret), K(*expr)); } else if (!expr->has_flag(CNT_ONETIME) || expr->has_flag(CNT_SUB_QUERY)) { // do nothing } else if (OB_FAIL(add_subquery_filter(expr))) { diff --git a/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/union_sort_opt.result b/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/union_sort_opt.result index 7c0b30864f..7974bdcce1 100644 --- a/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/union_sort_opt.result +++ b/tools/deploy/mysql_test/test_suite/optimizer/r/mysql/union_sort_opt.result @@ -1857,11 +1857,10 @@ Outputs & filters: 2 - output([UNION([1])], [UNION([2])], [UNION([3])], [UNION([4])], [UNION([5])], [UNION([6])], [UNION([7])], [UNION([8])], [UNION([9])]), filter([UNION([9]) IN (9727744, 7826688, 1657856, 55039, 50631)]), rowset=256 3 - output([table2_bigint.col_bigint], [table2_bigint.col_bigint_signed], [table2_bigint.col_bigint_unsigned], [table2_bigint.col_char_20], [table2_bigint.col_decimal_20_0], - [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_timestamp_6], [table2_bigint.pk]), f - ilter([cast(table2_bigint.col_decimal_20_0_unsigned, DECIMAL(20, 0)) != cast(99999, DECIMAL(5, 0))]), rowset=256 + [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_timestamp_6], [table2_bigint.pk]), filter([cast(table2_bigint.col_decimal_20_0_unsigned, + DECIMAL(20, 0)) != cast(99999, DECIMAL(5, 0))]), rowset=256 access([table2_bigint.pk], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_bigint], [table2_bigint.col_bigint_signed], [table2_bigint.col_bigint_unsigned], - [table2_bigint.col_char_20], [table2_bigint.col_decimal_20_0], [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_timestamp_6]), p - artitions(p0) + [table2_bigint.col_char_20], [table2_bigint.col_decimal_20_0], [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_timestamp_6]), partitions(p0) limit(5), offset(1), is_index_back=false, is_global_index=false, filter_before_indexback[false], range_key([table2_bigint.pk]), range(MIN ; MAX)always true 4 - output([UNION([1])], [UNION([2])], [UNION([3])], [UNION([4])], [UNION([5])], [UNION([6])], [UNION([7])], [UNION([8])], [UNION([9])]), filter(nil), rowset=256 @@ -1872,8 +1871,7 @@ Outputs & filters: 6 - output([table2_bigint.col_bigint], [table2_bigint.col_bigint_signed], [table2_bigint.col_bigint_unsigned], [table2_bigint.col_char_20], [table2_bigint.col_decimal_20_0], [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_timestamp_6], [table2_bigint.pk]), filter(nil), rowset=256 access([table2_bigint.pk], [table2_bigint.col_bigint], [table2_bigint.col_bigint_signed], [table2_bigint.col_bigint_unsigned], [table2_bigint.col_char_20], - [table2_bigint.col_decimal_20_0], [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_timestamp_6]), p - artitions(p0) + [table2_bigint.col_decimal_20_0], [table2_bigint.col_decimal_20_0_signed], [table2_bigint.col_decimal_20_0_unsigned], [table2_bigint.col_timestamp_6]), partitions(p0) is_index_back=false, is_global_index=false, range_key([table2_bigint.pk]), range[9727744 ; 9727744], [7826688 ; 7826688], [1657856 ; 1657856], [55039 ; 55039], [50631 ; 50631], range_cond([table2_bigint.pk IN (9727744, 7826688, 1657856, 55039, 50631)], [table2_bigint.pk IN (9727744, 7826688, 1657856, 55039, 50631)]) @@ -1885,11 +1883,10 @@ Outputs & filters: sort_keys([table100_bigint.col_bigint_signed, ASC], [table100_bigint.col_decimal_20_0_signed, ASC], [table100_bigint.col_decimal_20_0, ASC], [table100_bigint.pk, DESC]), topn(7) 9 - output([table100_bigint.pk], [table100_bigint.col_decimal_20_0_signed], [table100_bigint.col_decimal_20_0], [table100_bigint.col_bigint], [table100_bigint.col_bigint_signed], - [table100_bigint.col_bigint_unsigned], [table100_bigint.col_char_20], [table100_bigint.col_decimal_20_0_unsigned], [table100_bigint.col_timestamp_6]), f - ilter([table100_bigint.col_decimal_20_0_signed = cast(ROUND(SIGN(table100_bigint.col_decimal_20_0)), DECIMAL(-1, 0))]), rowset=256 + [table100_bigint.col_bigint_unsigned], [table100_bigint.col_char_20], [table100_bigint.col_decimal_20_0_unsigned], [table100_bigint.col_timestamp_6]), filter([table100_bigint.col_decimal_20_0_signed + = cast(ROUND(SIGN(table100_bigint.col_decimal_20_0)), DECIMAL(-1, 0))]), rowset=256 access([table100_bigint.pk], [table100_bigint.col_decimal_20_0_signed], [table100_bigint.col_decimal_20_0], [table100_bigint.col_bigint], [table100_bigint.col_bigint_signed], - [table100_bigint.col_bigint_unsigned], [table100_bigint.col_char_20], [table100_bigint.col_decimal_20_0_unsigned], [table100_bigint.col_timestamp_6]), p - artitions(p0) + [table100_bigint.col_bigint_unsigned], [table100_bigint.col_char_20], [table100_bigint.col_decimal_20_0_unsigned], [table100_bigint.col_timestamp_6]), partitions(p0) is_index_back=false, is_global_index=false, filter_before_indexback[false], range_key([table100_bigint.pk]), range(MIN ; MAX)always true SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk diff --git a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/table_insert.result b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/table_insert.result index 48ab71a136..aa246b5c40 100644 --- a/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/table_insert.result +++ b/tools/deploy/mysql_test/test_suite/static_engine/r/mysql/table_insert.result @@ -33,8 +33,7 @@ Outputs & filters: 0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10], [t1.c11], [t1.c12], [t1.c13], [t1.c14], [t1.c15], [t1.c16], [t1.c17], [t1.c18], [t1.c19], [t1.c20], [t1.c21], [t1.c22]), filter(nil), rowset=256 access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10], [t1.c11], [t1.c12], [t1.c13], [t1.c14], [t1.c15], - [t1.c16], [t1.c17], [t1.c18], [t1.c19], [t1.c20], [t1.c21], [t1.c22]), p - artitions(p0) + [t1.c16], [t1.c17], [t1.c18], [t1.c19], [t1.c20], [t1.c21], [t1.c22]), partitions(p0) is_index_back=false, is_global_index=false, range_key([t1.c1]), range(MIN ; MAX)always true select * from t1;