提交 ce5da320 编写于 作者: R rq0 提交者: wangzelin.wzl

fix size_overflow bug in distributed update

上级 ce819f8b
...@@ -204,20 +204,22 @@ int ObLogUpdate::allocate_exchange_post(AllocExchContext* ctx) ...@@ -204,20 +204,22 @@ int ObLogUpdate::allocate_exchange_post(AllocExchContext* ctx)
LOG_WARN("fail to copy subpart expr", K(ret)); LOG_WARN("fail to copy subpart expr", K(ret));
} else { } else {
CK(PARTITION_LEVEL_MAX != part_level); CK(PARTITION_LEVEL_MAX != part_level);
ObArray<ObRawExpr*> value_exprs;
for (int64_t assign_idx = 0; OB_SUCC(ret) && assign_idx < index_infos.at(i).assignments_.count(); for (int64_t assign_idx = 0; OB_SUCC(ret) && assign_idx < index_infos.at(i).assignments_.count();
assign_idx++) { assign_idx++) {
ObColumnRefRawExpr* col = index_infos.at(i).assignments_.at(assign_idx).column_expr_; ObColumnRefRawExpr* col = index_infos.at(i).assignments_.at(assign_idx).column_expr_;
ObRawExpr* value = index_infos.at(i).assignments_.at(assign_idx).expr_; ObRawExpr* value = index_infos.at(i).assignments_.at(assign_idx).expr_;
if (PARTITION_LEVEL_ZERO != part_level) { if (PARTITION_LEVEL_ZERO != part_level) {
if (OB_FAIL(ObRawExprUtils::replace_ref_column(new_part_expr, col, value))) { if (OB_FAIL(ObRawExprUtils::replace_ref_column(new_part_expr, col, value, NULL, &value_exprs))) {
LOG_WARN("fail to replace ref column", K(ret)); LOG_WARN("fail to replace ref column", K(ret));
} }
} }
if (PARTITION_LEVEL_TWO == part_level) { if (PARTITION_LEVEL_TWO == part_level) {
if (OB_FAIL(ObRawExprUtils::replace_ref_column(new_subpart_expr, col, value))) { if (OB_FAIL(ObRawExprUtils::replace_ref_column(new_subpart_expr, col, value, NULL, &value_exprs))) {
LOG_WARN("fail to replace ref column", K(ret)); LOG_WARN("fail to replace ref column", K(ret));
} }
} }
OZ(value_exprs.push_back(index_infos.at(i).assignments_.at(assign_idx).expr_));
} // for assignments end } // for assignments end
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
......
...@@ -1412,8 +1412,9 @@ int ObRawExprUtils::replace_all_ref_column( ...@@ -1412,8 +1412,9 @@ int ObRawExprUtils::replace_all_ref_column(
} }
// if %expr_factory is not NULL, will deep copy %to expr. default behavior is shallow copy // if %expr_factory is not NULL, will deep copy %to expr. default behavior is shallow copy
int ObRawExprUtils::replace_ref_column( // if except_exprs is not NULL, will skip the expr in except_exprs
ObRawExpr*& raw_expr, ObRawExpr* from, ObRawExpr* to, ObRawExprFactory* expr_factory) int ObRawExprUtils::replace_ref_column(ObRawExpr*& raw_expr, ObRawExpr* from, ObRawExpr* to,
ObRawExprFactory* expr_factory, const ObIArray<ObRawExpr*>* except_exprs)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_ISNULL(raw_expr) || OB_ISNULL(from) || OB_ISNULL(to)) { if (OB_ISNULL(raw_expr) || OB_ISNULL(from) || OB_ISNULL(to)) {
...@@ -1423,6 +1424,8 @@ int ObRawExprUtils::replace_ref_column( ...@@ -1423,6 +1424,8 @@ int ObRawExprUtils::replace_ref_column(
// do nothing // do nothing
// in case: parent(child) = to (from) // in case: parent(child) = to (from)
// replace as: parenet(child) = to (to) // replace as: parenet(child) = to (to)
} else if (NULL != except_exprs && is_contain(*except_exprs, raw_expr)) {
// do nothing
} else if (raw_expr == from) { } else if (raw_expr == from) {
if (NULL != expr_factory) { if (NULL != expr_factory) {
ObRawExpr* new_to = NULL; ObRawExpr* new_to = NULL;
...@@ -1446,14 +1449,14 @@ int ObRawExprUtils::replace_ref_column( ...@@ -1446,14 +1449,14 @@ int ObRawExprUtils::replace_ref_column(
LOG_WARN("get unexpected null", K(ret), K(ref_stmt)); LOG_WARN("get unexpected null", K(ret), K(ref_stmt));
} else if (OB_FAIL(ref_stmt->get_relation_exprs(relation_exprs))) { } else if (OB_FAIL(ref_stmt->get_relation_exprs(relation_exprs))) {
LOG_WARN("failed to get relation exprs", K(ret)); LOG_WARN("failed to get relation exprs", K(ret));
} else if (OB_FAIL(SMART_CALL(replace_ref_column(relation_exprs, from, to)))) { } else if (OB_FAIL(SMART_CALL(replace_ref_column(relation_exprs, from, to, except_exprs)))) {
LOG_WARN("replace reference column failed", K(ret)); LOG_WARN("replace reference column failed", K(ret));
} }
} else { } else {
int64_t N = raw_expr->get_param_count(); int64_t N = raw_expr->get_param_count();
for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) {
ObRawExpr*& child_expr = raw_expr->get_param_expr(i); ObRawExpr*& child_expr = raw_expr->get_param_expr(i);
if (OB_FAIL(SMART_CALL(replace_ref_column(child_expr, from, to, expr_factory)))) { if (OB_FAIL(SMART_CALL(replace_ref_column(child_expr, from, to, expr_factory, except_exprs)))) {
LOG_WARN("replace reference column failed", K(ret)); LOG_WARN("replace reference column failed", K(ret));
} }
} // end for } // end for
...@@ -1461,7 +1464,8 @@ int ObRawExprUtils::replace_ref_column( ...@@ -1461,7 +1464,8 @@ int ObRawExprUtils::replace_ref_column(
return ret; return ret;
} }
int ObRawExprUtils::replace_ref_column(ObIArray<ObRawExpr*>& exprs, ObRawExpr* from, ObRawExpr* to) int ObRawExprUtils::replace_ref_column(
ObIArray<ObRawExpr*>& exprs, ObRawExpr* from, ObRawExpr* to, const ObIArray<ObRawExpr*>* except_exprs)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
bool is_stack_overflow = false; bool is_stack_overflow = false;
...@@ -1479,7 +1483,7 @@ int ObRawExprUtils::replace_ref_column(ObIArray<ObRawExpr*>& exprs, ObRawExpr* f ...@@ -1479,7 +1483,7 @@ int ObRawExprUtils::replace_ref_column(ObIArray<ObRawExpr*>& exprs, ObRawExpr* f
ObRawExpr*& raw_expr = tmp_raw_expr; ObRawExpr*& raw_expr = tmp_raw_expr;
if (OB_FAIL(exprs.at(i, raw_expr))) { if (OB_FAIL(exprs.at(i, raw_expr))) {
LOG_WARN("failed to get raw expr", K(i), K(ret)); LOG_WARN("failed to get raw expr", K(i), K(ret));
} else if (OB_FAIL(SMART_CALL(replace_ref_column(raw_expr, from, to)))) { } else if (OB_FAIL(SMART_CALL(replace_ref_column(raw_expr, from, to, NULL, except_exprs)))) {
LOG_WARN("failed to replace_ref_column", K(from), K(to), K(ret)); LOG_WARN("failed to replace_ref_column", K(from), K(to), K(ret));
} else { /*do nothing*/ } else { /*do nothing*/
} }
......
...@@ -211,10 +211,12 @@ public: ...@@ -211,10 +211,12 @@ public:
/// replace all `from' to `to' in the raw_expr /// replace all `from' to `to' in the raw_expr
static int replace_all_ref_column(ObRawExpr*& raw_expr, const common::ObIArray<ObRawExpr*>& exprs, int64_t& offset); static int replace_all_ref_column(ObRawExpr*& raw_expr, const common::ObIArray<ObRawExpr*>& exprs, int64_t& offset);
// if %expr_factory is not NULL, will deep copy %to expr. default behavior is shallow copy // if %expr_factory is not NULL, will deep copy %to expr. default behavior is shallow copy
static int replace_ref_column( // if except_exprs is not NULL, will skip the expr in except_exprs
ObRawExpr*& raw_expr, ObRawExpr* from, ObRawExpr* to, ObRawExprFactory* expr_factory = NULL); static int replace_ref_column(ObRawExpr*& raw_expr, ObRawExpr* from, ObRawExpr* to,
ObRawExprFactory* expr_factory = NULL, const ObIArray<ObRawExpr*>* except_exprs = NULL);
static int replace_level_column(ObRawExpr*& raw_expr, ObRawExpr* to, bool& replaced); static int replace_level_column(ObRawExpr*& raw_expr, ObRawExpr* to, bool& replaced);
static int replace_ref_column(common::ObIArray<ObRawExpr*>& exprs, ObRawExpr* from, ObRawExpr* to); static int replace_ref_column(common::ObIArray<ObRawExpr*>& exprs, ObRawExpr* from, ObRawExpr* to,
const ObIArray<ObRawExpr*>* except_exprs = NULL);
static bool all_column_exprs(const common::ObIArray<ObRawExpr*>& exprs); static bool all_column_exprs(const common::ObIArray<ObRawExpr*>& exprs);
/// extract column exprs from the raw expr /// extract column exprs from the raw expr
static int extract_column_exprs(const ObRawExpr* raw_expr, common::ObIArray<ObRawExpr*>& column_exprs); static int extract_column_exprs(const ObRawExpr* raw_expr, common::ObIArray<ObRawExpr*>& column_exprs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册