cp bug fix to open source branch

This commit is contained in:
obdev
2021-07-20 17:06:14 +08:00
committed by wangzelin.wzl
parent 91bb0da2ae
commit f45d2cdbe2
37 changed files with 766 additions and 628 deletions

View File

@ -1128,7 +1128,7 @@ int ObLogPlan::generate_semi_join_detectors(const ObIArray<SemiInfo*>& semi_info
LOG_WARN("unexpect null conflict detector", K(ret));
} else if (OB_FAIL(detector->L_DS_.add_members(left_rel_ids))) {
LOG_WARN("failed to add members", K(ret));
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, info->right_table_id_, right_rel_ids))) {
} else if (OB_FAIL(stmt->get_table_rel_ids(info->right_table_id_, right_rel_ids))) {
LOG_WARN("failed to get table ids", K(ret));
} else if (OB_FAIL(detector->R_DS_.add_members(right_rel_ids))) {
LOG_WARN("failed to add members", K(ret));
@ -2382,7 +2382,7 @@ int ObLogPlan::init_leading_info_from_tables(
right_rel_ids.reuse();
if (OB_ISNULL(semi_info)) {
LOG_WARN("unexpect null semi info", K(ret));
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, semi_info->right_table_id_, right_rel_ids))) {
} else if (OB_FAIL(stmt->get_table_rel_ids(semi_info->right_table_id_, right_rel_ids))) {
LOG_WARN("failed to get table ids", K(ret));
} else if (OB_FAIL(hint_info.left_table_set_.add_members(leading_tables_))) {
LOG_WARN("failed to add table ids", K(ret));

View File

@ -143,6 +143,12 @@ int ObMergeLogPlan::allocate_merge_subquery()
LOG_WARN("failed to allocate delete condition subquery", K(ret));
} else if (OB_FAIL(merge_stmt->formalize_stmt_expr_reference())) {
LOG_WARN("failed to formalize stmt expr reference", K(ret));
} else if (condition_subquery_exprs.empty() && target_subquery_exprs.empty() &&
delete_subquery_exprs.empty() && !merge_stmt->get_match_condition_exprs().empty()) {
// alloc subplan filter for subquery in match condition
if (OB_FAIL(candi_allocate_subplan_filter(merge_stmt->get_match_condition_exprs(), false))) {
LOG_WARN("failed to allocate subplan filter", K(ret));
}
} else if (!condition_subquery_exprs.empty() &&
OB_FAIL(candi_allocate_subplan_filter(condition_subquery_exprs, false))) {
LOG_WARN("failed to allocate subplan filter", K(ret));

View File

@ -4961,28 +4961,38 @@ int ObOptimizerUtil::get_set_res_types(ObIAllocator* allocator, ObSQLSessionInfo
ObExprResType res_type;
const int64_t child_num = child_querys.count();
const int64_t select_num = select_stmt->get_select_item_size();
ObRawExpr* expr = NULL;
for (int64_t i = 1; OB_SUCC(ret) && i < child_num; ++i) {
if (OB_ISNULL(child_querys.at(i))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected set stmt", K(ret), K(child_querys), K(select_stmt));
} else if (OB_UNLIKELY(select_num != child_querys.at(i)->get_select_item_size())) {
ret = OB_ERR_COLUMN_SIZE;
LOG_WARN("The used SELECT statements have a different number of columns",
K(select_num),
K(select_stmt->get_select_item_size()));
}
}
ObSelectStmt *cur_stmt = NULL;
bool is_all_not_null = true;
bool is_on_null_side = false;
ObColumnRefRawExpr *col_expr = NULL;
ObRawExpr *expr = NULL;
for (int64_t idx = 0; OB_SUCC(ret) && idx < select_num; ++idx) {
bool is_all_not_null = true;
types.reuse();
is_all_not_null = true;
res_type.unset_result_flag(NOT_NULL_FLAG);
for (int64_t i = 0; OB_SUCC(ret) && i < child_num; ++i) {
types.reuse();
if (OB_ISNULL(expr = select_stmt->get_select_item(idx).expr_)) {
if (OB_ISNULL(cur_stmt = child_querys.at(i)) ||
OB_UNLIKELY(idx >= cur_stmt->get_select_item_size()) ||
OB_ISNULL(expr = cur_stmt->get_select_item(idx).expr_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret), K(expr));
LOG_WARN("unexpected child stmt", K(ret), K(cur_stmt), K(expr));
} else if (OB_FAIL(add_var_to_array_no_dup(types, expr->get_result_type()))) {
LOG_WARN("unexpected null", K(ret), K(expr->get_result_type()));
} else if (is_all_not_null && !expr->get_result_type().has_result_flag(OB_MYSQL_NOT_NULL_FLAG)) {
LOG_WARN("failed to add var", K(ret), K(expr->get_result_type()));
} else if (!is_all_not_null) {
/* do nothing */
} else if (!expr->is_column_ref_expr()) {
is_all_not_null = false;
} else if (OB_FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(expr))) {
} else if (!col_expr->get_result_type().has_result_flag(NOT_NULL_FLAG)) {
is_all_not_null = false;
} else if (NULL == cur_stmt->get_table_item_by_id(col_expr->get_table_id())) {
// column expr from upper stmt, ignore NOT NULL FLAG
is_all_not_null = false;
} else if (OB_FAIL(ObOptimizerUtil::is_table_on_null_side(cur_stmt,
col_expr->get_table_id(),
is_on_null_side))) {
LOG_WARN("check is table on null side failed", K(ret));
} else if (is_on_null_side) {
is_all_not_null = false;
}
}
@ -5006,9 +5016,11 @@ int ObOptimizerUtil::get_set_res_types(ObIAllocator* allocator, ObSQLSessionInfo
if (OB_FAIL(ret)) {
} else if (OB_UNLIKELY(res_types.empty())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected empty", K(ret), K(types.empty()));
} else if (!is_all_not_null) {
res_types.at(res_types.count() - 1).unset_result_flag(OB_MYSQL_NOT_NULL_FLAG);
LOG_WARN("unexpected empty", K(ret), K(res_types.empty()));
} else if (is_all_not_null) {
res_types.at(res_types.count()-1).set_result_flag(NOT_NULL_FLAG);
} else {
res_types.at(res_types.count()-1).unset_result_flag(NOT_NULL_FLAG);
}
}
}
@ -5093,7 +5105,7 @@ int ObOptimizerUtil::try_add_cast_to_set_child_list(ObIAllocator* allocator, ObS
}
const ObLengthSemantics length_semantics = session_info->get_actual_nls_length_semantics();
if (OB_FAIL(ret)) {
} else if (OB_FAIL(types.push_back(left_type) || OB_FAIL(types.push_back(right_type)))) {
} else if (OB_FAIL(types.push_back(left_type)) || OB_FAIL(types.push_back(right_type))) {
LOG_WARN("failed to push back", K(ret));
} else if (OB_FAIL(session_info->get_collation_connection(coll_type))) {
LOG_WARN("failed to get collation connection", K(ret));

View File

@ -291,6 +291,7 @@ public:
INDEX_STORE_RELATED = -2, // has column not index column, but storing column
MUL_INDEX_COL = -1, // has more than one index columns in expr not row.some case present not prefix filter
};
static int get_subquery_id(const ObDMLStmt* upper_stmt, const ObSelectStmt* stmt, uint64_t& id);
static int get_child_corresponding_exprs(const ObDMLStmt* upper_stmt, const ObSelectStmt* stmt,