fix bug case when expr can't do batch_execute optimization

This commit is contained in:
yishenglanlingzui
2023-01-28 20:37:21 +08:00
committed by ob-robot
parent 0f14606391
commit 4bb1033505
3 changed files with 33 additions and 0 deletions

View File

@ -729,10 +729,18 @@ int ObUpdateResolver::generate_batched_stmt_info()
for (int64_t j = 0; OB_SUCC(ret) && j < assignments.count(); ++j) {
ObAssignment &assignment = assignments.at(j);
ObRawExpr *column_expr = assignment.column_expr_;
bool contain_case_when = false;
if (has_exist_in_array(predicate_columns, column_expr)) {
assignment.is_predicate_column_ = true;
} else if (OB_FAIL(ObRawExprUtils::check_contain_case_when_exprs(assignment.expr_,
contain_case_when))) {
LOG_WARN("fail to check contain case when", K(ret), K(assignment));
} else if (contain_case_when) {
ret = OB_BATCHED_MULTI_STMT_ROLLBACK;
LOG_TRACE("batched multi stmt contain case when expr", K(ret));
}
}
}
}
}

View File

@ -7842,5 +7842,29 @@ int ObRawExprUtils::is_contain_params(const ObRawExpr *expr, bool &is_contain)
return ret;
}
int ObRawExprUtils::check_contain_case_when_exprs(const ObRawExpr *raw_expr, bool &contain)
{
int ret = OB_SUCCESS;
bool is_stack_overflow = false;
if (OB_ISNULL(raw_expr)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("expr passed in is NULL", K(ret));
} else if (OB_FAIL(check_stack_overflow(is_stack_overflow))) {
LOG_WARN("check stack overflow failed", K(ret));
} else if (is_stack_overflow) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("too deep recursive", K(ret));
} else if (raw_expr->get_expr_type() == T_OP_CASE) {
contain = true;
} else {
for (int64_t i = 0; OB_SUCC(ret) && !contain && i < raw_expr->get_param_count(); i++) {
if (OB_FAIL(SMART_CALL(check_contain_case_when_exprs(raw_expr->get_param_expr(i), contain)))) {
LOG_WARN("failed to replace_ref_column", KPC(raw_expr), K(i));
}
}
}
return ret;
}
}
}

View File

@ -1053,6 +1053,7 @@ public:
const ObSQLSessionInfo &session_info,
const share::schema::ObTableSchema &index_schema,
ObColumnRefRawExpr *&spk_expr);
static int check_contain_case_when_exprs(const ObRawExpr *raw_expr, bool &contain);
private :