fix single partition opt bug

This commit is contained in:
bf0
2021-09-24 11:10:39 +08:00
committed by wangzelin.wzl
parent 86697041a2
commit 73e3401749
9 changed files with 87 additions and 40 deletions

View File

@ -690,6 +690,7 @@ int ObLogInsert::need_multi_table_dml(AllocExchContext& ctx, ObShardingInfo& sha
bool has_rand_part_key = false;
bool has_subquery_part_key = false;
bool trigger_exist = false;
bool is_one_part_table = false;
bool is_match = false;
ObInsertStmt* insert_stmt = static_cast<ObInsertStmt*>(get_stmt());
is_needed = false;
@ -702,9 +703,12 @@ int ObLogInsert::need_multi_table_dml(AllocExchContext& ctx, ObShardingInfo& sha
} else if (OB_ISNULL(tbl_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("table schema is null", K(ret), K(insert_stmt));
} else if (FALSE_IT(is_one_part_table = ObSQLUtils::is_one_part_table_can_skip_part_calc(*tbl_schema))) {
} else if (insert_stmt->is_ignore() && !is_one_part_table) {
is_needed = true;
} else if (modify_multi_tables()) {
is_needed = true;
} else if (is_table_update_part_key() && tbl_schema->get_all_part_num() > 1) {
} else if (is_table_update_part_key() && !is_one_part_table) {
is_needed = true;
}
@ -731,12 +735,16 @@ int ObLogInsert::need_multi_table_dml(AllocExchContext& ctx, ObShardingInfo& sha
} else if (get_part_hint() != NULL && insert_stmt->value_from_select()) {
is_needed = true;
} else if (target_sharding_info.is_local()) {
is_needed = false;
sharding_info.copy_with_part_keys(target_sharding_info);
if (is_one_part_table || !table_partition_info_.get_table_location().is_all_partition()) {
is_needed = false;
sharding_info.copy_with_part_keys(target_sharding_info);
} else {
is_needed = true;
}
} else if (OB_FAIL(input_sharding.push_back(&target_sharding_info)) ||
OB_FAIL(input_sharding.push_back(&child->get_sharding_info()))) {
LOG_WARN("failed to push back sharding info", K(ret));
} else if (ObLogicalOperator::compute_basic_sharding_info(input_sharding, output_sharding, is_basic)) {
} else if (OB_FAIL(ObLogicalOperator::compute_basic_sharding_info(input_sharding, output_sharding, is_basic))) {
LOG_WARN("failed to compute basic sharding info", K(ret));
} else if (is_basic) {
is_needed = false;