feat: add the rule to use-das when has variable assignments in sql

Co-authored-by: leslieyuchen <leslieyuchen@gmail.com>
This commit is contained in:
obdev
2023-10-23 09:14:02 +00:00
committed by ob-robot
parent a46ee110fb
commit bacc417957
23 changed files with 170 additions and 18 deletions

View File

@ -3340,6 +3340,29 @@ int ObRawExprUtils::extract_set_op_exprs(const ObRawExpr *raw_expr,
return ret;
}
int ObRawExprUtils::extract_var_assign_exprs(const ObRawExpr *raw_expr,
ObIArray<ObRawExpr*> &assign_exprs)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(raw_expr)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid raw expr", K(ret), K(raw_expr));
} else if (raw_expr->has_flag(IS_ASSIGN_EXPR) && raw_expr->get_relation_ids().is_empty()) {
if (OB_FAIL(add_var_to_array_no_dup(assign_exprs, const_cast<ObRawExpr*>(raw_expr)))) {
LOG_WARN("failed to append expr", K(ret));
}
} else {
int64_t N = raw_expr->get_param_count();
for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) {
if (OB_FAIL(SMART_CALL(extract_var_assign_exprs(raw_expr->get_param_expr(i),
assign_exprs)))) {
LOG_WARN("failed to extract var assign op exprs", K(ret));
}
}
}
return ret;
}
int ObRawExprUtils::extract_set_op_exprs(const ObIArray<ObRawExpr*> &exprs,
common::ObIArray<ObRawExpr*> &set_op_exprs)
{