fix count_to_exists bug
This commit is contained in:
parent
ea81e24605
commit
5c2a7ab5d9
@ -275,7 +275,7 @@ int ObTransformCountToExists::get_trans_type(ObRawExpr *expr, ObRawExpr *&val_pa
|
|||||||
if (OB_ISNULL(first_param) || OB_ISNULL(second_param)) {
|
if (OB_ISNULL(first_param) || OB_ISNULL(second_param)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("get unexpected null", K(ret), K(first_param), K(second_param));
|
LOG_WARN("get unexpected null", K(ret), K(first_param), K(second_param));
|
||||||
} else if (first_param->is_const_expr() && second_param->is_query_ref_expr()) {
|
} else if (first_param->is_static_scalar_const_expr() && second_param->is_query_ref_expr()) {
|
||||||
val_param = first_param;
|
val_param = first_param;
|
||||||
subquery_param = second_param;
|
subquery_param = second_param;
|
||||||
switch (expr->get_expr_type()) {
|
switch (expr->get_expr_type()) {
|
||||||
@ -289,7 +289,7 @@ int ObTransformCountToExists::get_trans_type(ObRawExpr *expr, ObRawExpr *&val_pa
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (first_param->is_query_ref_expr() && second_param->is_const_expr()) {
|
} else if (first_param->is_query_ref_expr() && second_param->is_static_scalar_const_expr()) {
|
||||||
subquery_param = first_param;
|
subquery_param = first_param;
|
||||||
val_param = second_param;
|
val_param = second_param;
|
||||||
switch (expr->get_expr_type()) {
|
switch (expr->get_expr_type()) {
|
||||||
@ -325,9 +325,6 @@ int ObTransformCountToExists::check_sel_expr_valid(ObRawExpr *select_expr,
|
|||||||
} else if (OB_ISNULL(param = select_expr->get_param_expr(0))) {
|
} else if (OB_ISNULL(param = select_expr->get_param_expr(0))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("get unexpected null", K(ret));
|
LOG_WARN("get unexpected null", K(ret));
|
||||||
} else if (param->is_const_expr()) {
|
|
||||||
// count(const)
|
|
||||||
is_sel_expr_valid = true;
|
|
||||||
} else if (!param->has_flag(CNT_SUB_QUERY)) {
|
} else if (!param->has_flag(CNT_SUB_QUERY)) {
|
||||||
is_sel_expr_valid = true;
|
is_sel_expr_valid = true;
|
||||||
count_param = param;
|
count_param = param;
|
||||||
@ -404,7 +401,18 @@ int ObTransformCountToExists::do_transform(ObDMLStmt *stmt,
|
|||||||
// ->
|
// ->
|
||||||
// select * from t1 where exists (select 1 from t1 where to_char(c1, '') is not null);
|
// select * from t1 where exists (select 1 from t1 where to_char(c1, '') is not null);
|
||||||
ObRawExpr *not_null_cond = NULL;
|
ObRawExpr *not_null_cond = NULL;
|
||||||
if (OB_FAIL(ObRawExprUtils::build_is_not_null_expr(*ctx_->expr_factory_,
|
bool is_not_null = true;
|
||||||
|
ObArray<ObRawExpr *> constraints;
|
||||||
|
if (OB_FAIL(ObTransformUtils::is_expr_not_null(ctx_, subquery, trans_param.count_param_,
|
||||||
|
NULLABLE_SCOPE::NS_WHERE,
|
||||||
|
is_not_null,
|
||||||
|
&constraints))) {
|
||||||
|
LOG_WARN("failed to check whether expr is nullable", K(ret));
|
||||||
|
} else if (is_not_null) {
|
||||||
|
if (OB_FAIL(ObTransformUtils::add_param_not_null_constraint(*ctx_, constraints))) {
|
||||||
|
LOG_WARN("failed to add param not null constraint", K(ret));
|
||||||
|
}
|
||||||
|
} else if (OB_FAIL(ObRawExprUtils::build_is_not_null_expr(*ctx_->expr_factory_,
|
||||||
trans_param.count_param_,
|
trans_param.count_param_,
|
||||||
true,
|
true,
|
||||||
not_null_cond))) {
|
not_null_cond))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user