[CP] Fix shared expr bug and datetime bug

This commit is contained in:
obdev
2022-11-11 03:37:18 +00:00
committed by wangzelin.wzl
parent 385bda30b9
commit 9da9109c53
7 changed files with 220 additions and 27 deletions

View File

@ -856,13 +856,34 @@ int ObSelectResolver::check_group_by()
// 1. select item/having/order item中的表达式树(子树)需要每个都在group by列中找到
// 2. 递归查找是否在groupby列中,将在groupby的列的指针替换。
if (OB_SUCC(ret)) {
if (ObTransformUtils::replace_stmt_expr_with_groupby_exprs(select_stmt)) {
if (OB_FAIL(replace_stmt_expr_with_groupby_exprs(select_stmt, params_.query_ctx_))) {
LOG_WARN("failed to replace stmt expr with groupby columns", K(ret));
}
}
return ret;
}
int ObSelectResolver::replace_stmt_expr_with_groupby_exprs(ObSelectStmt *select_stmt,
ObQueryCtx *query_ctx)
{
int ret = OB_SUCCESS;
ObSEArray<ObPCConstParamInfo, 4> pc_constraints;
ObSEArray<ObPCParamEqualInfo, 4> eq_constraints;
if (OB_ISNULL(query_ctx)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret), K(query_ctx));
} else if (OB_FAIL(ObTransformUtils::inner_replace_stmt_expr_with_groupby_exprs(select_stmt, params_.param_list_, pc_constraints, eq_constraints))) {
LOG_WARN("failed to replace stmt expr with groupby columns", K(ret));
} else if (OB_FAIL(append_array_no_dup(query_ctx->all_plan_const_param_constraints_, pc_constraints))) {
LOG_WARN("failed to append const param info", K(ret));
} else if (OB_FAIL(append_array_no_dup(query_ctx->all_possible_const_param_constraints_, pc_constraints))) {
LOG_WARN("failed to append const param info", K(ret));
} else if (OB_FAIL(append_array_no_dup(query_ctx->all_equal_param_constraints_, eq_constraints))) {
LOG_WARN("failed to append const param info", K(ret));
}
return ret;
}
// 1. lob type can't be ordered
// 2. the order item should be exists in select items if has distinct
int ObSelectResolver::check_order_by()

View File

@ -428,6 +428,8 @@ private:
int add_name_for_anonymous_view();
int add_name_for_anonymous_view_recursive(TableItem *table_item);
int replace_stmt_expr_with_groupby_exprs(ObSelectStmt *select_stmt, ObQueryCtx *query_ctx);
protected:
// data members
/*these member is only for with clause*/