[CP] Fix a dblink bug

This commit is contained in:
xianyu-w
2023-12-19 19:13:32 +00:00
committed by ob-robot
parent 99460862e3
commit 78d2ca9b27
2 changed files with 25 additions and 8 deletions

View File

@ -503,14 +503,29 @@ int ObTransformDBlink::has_invalid_link_expr(ObDMLStmt &stmt, bool &has_invalid_
has_invalid_expr = false; has_invalid_expr = false;
if (OB_FAIL(stmt.get_relation_exprs(exprs))) { if (OB_FAIL(stmt.get_relation_exprs(exprs))) {
LOG_WARN("failed to get relation exprs", K(ret)); LOG_WARN("failed to get relation exprs", K(ret));
} else { } else if (OB_FAIL(has_invalid_link_expr(exprs, has_invalid_expr))) {
for (int64_t i = 0; OB_SUCC(ret) && !has_invalid_expr && i < exprs.count(); i++) { LOG_WARN("failed to check has invalid link expr", K(ret));
bool is_valid = false; } else if (has_invalid_expr) {
if (OB_FAIL(check_link_expr_valid(exprs.at(i), is_valid))) { // do nothing
LOG_WARN("failed to check link expr valid", KPC(exprs.at(i)), K(ret)); } else if (stmt.is_insert_stmt()) {
} else if (!is_valid) { // get_relation_exprs can not get all exprs in values vector
has_invalid_expr = true; if (OB_FAIL(has_invalid_link_expr(static_cast<ObInsertStmt &>(stmt).get_values_vector(), has_invalid_expr))) {
} LOG_WARN("failed to check has invalid link expr", K(ret));
}
}
return ret;
}
int ObTransformDBlink::has_invalid_link_expr(ObIArray<ObRawExpr *> &exprs, bool &has_invalid_expr)
{
int ret = OB_SUCCESS;
has_invalid_expr = false;
for (int64_t i = 0; OB_SUCC(ret) && !has_invalid_expr && i < exprs.count(); i++) {
bool is_valid = false;
if (OB_FAIL(check_link_expr_valid(exprs.at(i), is_valid))) {
LOG_WARN("failed to check link expr valid", KPC(exprs.at(i)), K(ret));
} else if (!is_valid) {
has_invalid_expr = true;
} }
} }
return ret; return ret;

View File

@ -175,6 +175,8 @@ private:
int has_invalid_link_expr(ObDMLStmt &stmt, bool &has_invalid_expr); int has_invalid_link_expr(ObDMLStmt &stmt, bool &has_invalid_expr);
int has_invalid_link_expr(ObIArray<ObRawExpr *> &exprs, bool &has_invalid_expr);
static int check_link_expr_valid(ObRawExpr *expr, bool &is_valid); static int check_link_expr_valid(ObRawExpr *expr, bool &is_valid);
DISALLOW_COPY_AND_ASSIGN(ObTransformDBlink); DISALLOW_COPY_AND_ASSIGN(ObTransformDBlink);