deep copy stmt need copy user var exprs

This commit is contained in:
yb0 2021-11-19 14:39:44 +08:00 committed by LINxiansheng
parent 728762d35e
commit a67bf40128
2 changed files with 22 additions and 7 deletions

View File

@ -635,6 +635,9 @@ int ObDMLStmt::deep_copy_stmt_struct(
} else if (OB_FAIL(ObRawExprUtils::copy_expr(
expr_factory, other.limit_percent_expr_, limit_percent_expr_, COPY_REF_DEFAULT))) {
LOG_WARN("deep copy limit percent expr failed", K(ret));
} else if (OB_FAIL(
ObRawExprUtils::copy_exprs(expr_factory, other.user_var_exprs_, user_var_exprs_, COPY_REF_DEFAULT))) {
LOG_WARN("deep copy user var exprs failed", K(ret));
} else if (OB_FAIL(from_items_.assign(other.from_items_))) {
LOG_WARN("assign from items failed", K(ret));
} else if (OB_FAIL(stmt_hint_.assign(other.stmt_hint_))) {

View File

@ -2151,14 +2151,26 @@ int ObRawExprUtils::copy_expr(ObRawExprFactory& expr_factory, const ObRawExpr* o
break;
}
case ObRawExpr::EXPR_CONST: {
ObConstRawExpr* dest_const = NULL;
const ObConstRawExpr* origin_const = static_cast<const ObConstRawExpr*>(origin);
if (OB_FAIL(expr_factory.create_raw_expr(origin->get_expr_type(), dest_const)) || OB_ISNULL(dest_const)) {
LOG_WARN("failed to allocate raw expr", K(dest_const), K(ret));
} else if (OB_FAIL(dest_const->deep_copy(expr_factory, *origin_const, COPY_REF_DEFAULT, use_new_allocator))) {
LOG_WARN("failed to deep copy const expr", K(ret));
if (T_USER_VARIABLE_IDENTIFIER == origin->get_expr_type()) {
ObUserVarIdentRawExpr* dest_expr = NULL;
const ObUserVarIdentRawExpr* origin_expr = static_cast<const ObUserVarIdentRawExpr*>(origin);
if (OB_FAIL(expr_factory.create_raw_expr(origin->get_expr_type(), dest_expr)) || OB_ISNULL(dest_expr)) {
LOG_WARN("failed to allocate raw expr", K(dest_expr), K(ret));
} else if (OB_FAIL(dest_expr->deep_copy(expr_factory, *origin_expr, COPY_REF_DEFAULT, use_new_allocator))) {
LOG_WARN("failed to deep copy const expr", K(ret));
} else {
dest = dest_expr;
}
} else {
dest = dest_const;
ObConstRawExpr *dest_const = NULL;
const ObConstRawExpr *origin_const = static_cast<const ObConstRawExpr *>(origin);
if (OB_FAIL(expr_factory.create_raw_expr(origin->get_expr_type(), dest_const)) || OB_ISNULL(dest_const)) {
LOG_WARN("failed to allocate raw expr", K(dest_const), K(ret));
} else if (OB_FAIL(dest_const->deep_copy(expr_factory, *origin_const, COPY_REF_DEFAULT, use_new_allocator))) {
LOG_WARN("failed to deep copy const expr", K(ret));
} else {
dest = dest_const;
}
}
break;
}