提交 1be6c41e 编写于 作者: O obdev 提交者: ob-robot

Fix failed mysqltests caused by fixing rollup shared exprs bug and fixing core at inner_same_as

上级 06d62f76
......@@ -326,6 +326,7 @@ int ObGroupByChecker::add_pc_const_param_info(ObExprEqualCheckContext &check_ctx
bool ObGroupByChecker::find_in_rollup(ObRawExpr &expr)
{
bool found = false;
bool found_same_structure = false;
ObStmtCompareContext check_ctx;
int ret = OB_SUCCESS;
if (OB_ISNULL(query_ctx_)) {
......@@ -352,7 +353,7 @@ bool ObGroupByChecker::find_in_rollup(ObRawExpr &expr)
check_ctx.override_const_compare_ = true;
check_ctx.override_query_compare_ = true;
if (expr.same_as(*rollup_exprs_->at(nth_rollup), &check_ctx)) {
found = true;
found_same_structure = true;
LOG_DEBUG("found same structure in rollup exprs", K(expr));
}
}
......@@ -360,7 +361,7 @@ bool ObGroupByChecker::find_in_rollup(ObRawExpr &expr)
}
}
if (OB_FAIL(ret)) {
} else if (found && OB_SUCCESS == check_ctx.err_code_) {
} else if ((found || found_same_structure) && OB_SUCCESS == check_ctx.err_code_) {
if (OB_FAIL(append(query_ctx_->all_equal_param_constraints_,
check_ctx.equal_param_info_))) {
LOG_WARN("failed to append equal params constraints", K(ret));
......@@ -416,6 +417,7 @@ bool ObGroupByChecker::find_in_grouping_sets(ObRawExpr &expr)
{
int ret = OB_SUCCESS;
bool found = false;
bool found_same_structure = false;
ObStmtCompareContext check_ctx;
if (OB_ISNULL(query_ctx_)) {
ret = OB_ERR_UNEXPECTED;
......@@ -436,9 +438,26 @@ bool ObGroupByChecker::find_in_grouping_sets(ObRawExpr &expr)
}
}
}
if (OB_SUCCESS == check_ctx.err_code_ && !found && is_top_select_stmt()) {
for (int64_t nth_gs = 0; !found && nth_gs < gs_cnt; ++nth_gs) {
int64_t group_by_cnt = grouping_sets_exprs_->at(nth_gs).groupby_exprs_.count();
//in oracle mode, only non static const expr will be replaced later in replace_group_by_exprs
for (int64_t nth_group_by = 0; !found && nth_group_by < group_by_cnt; ++nth_group_by) {
check_ctx.reset();
check_ctx.ignore_param_ = true;
check_ctx.override_const_compare_ = true;
check_ctx.override_query_compare_ = true;
if (expr.same_as(*grouping_sets_exprs_->at(nth_gs).groupby_exprs_.at(nth_group_by),
&check_ctx)) {
found_same_structure = true;
LOG_DEBUG("found in grouping sets exprs", K(expr));
}
}
}
}
}
if (OB_FAIL(ret)) {
} else if (found && OB_SUCCESS == check_ctx.err_code_ && lib::is_oracle_mode()) {
} else if ((found || found_same_structure) && OB_SUCCESS == check_ctx.err_code_ && lib::is_oracle_mode()) {
if (OB_FAIL(append(query_ctx_->all_equal_param_constraints_,
check_ctx.equal_param_info_))) {
LOG_WARN("failed to append equal params constraints", K(ret));
......@@ -605,7 +624,7 @@ int ObGroupByChecker::visit(ObConstRawExpr &expr)
}
} else if (find_in_rollup(expr) || find_in_grouping_sets(expr)) {
set_skip_expr(&expr);
} else if (OB_FAIL(add_abs_equal_constraint_in_grouping_sets(expr))) {
} else if (OB_FAIL(add_abs_equal_constraint_in_grouping_sets(expr))) {
LOG_WARN("fail to add abs_equal constraintd", K(ret));
}
return ret;
......
......@@ -3388,7 +3388,8 @@ bool ObSysFunRawExpr::inner_same_as(
if (get_expr_type() != expr.get_expr_type()) {
} else if (T_FUN_SYS_RAND == get_expr_type()
|| T_FUN_SYS_GUID == get_expr_type()) {
} else if (expr.is_sys_func_expr()) {
} else if (get_expr_class() == expr.get_expr_class()) {
//for EXPR_UDF and EXPR_SYS_FUNC
const ObSysFunRawExpr *s_expr = static_cast<const ObSysFunRawExpr *>(&expr);
if (ObCharset::case_insensitive_equal(func_name_, s_expr->get_func_name())
&& this->get_param_count() == s_expr->get_param_count()) {
......
......@@ -9256,7 +9256,8 @@ int ObTransformUtils::replace_with_groupby_exprs(ObSelectStmt *select_stmt,
if (OB_ISNULL(groupby_exprs.at(i))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("got an unexpected null", K(ret));
} else if (groupby_exprs.at(i)->same_as(*expr, &check_context)) {
} else if ((is_mysql_mode() || !expr->is_static_const_expr())
&& groupby_exprs.at(i)->same_as(*expr, &check_context)) {
expr = groupby_exprs.at(i);
is_existed = true;
} else { /*do nothing.*/ }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册