提交 4c8ccd1f 编写于 作者: O obdev 提交者: wangzelin.wzl

[CP] fix shared exprs bug after view merge

上级 81366295
...@@ -9170,16 +9170,17 @@ int ObCodeGeneratorImpl::get_cell_idx( ...@@ -9170,16 +9170,17 @@ int ObCodeGeneratorImpl::get_cell_idx(
if (OB_ISNULL(raw_expr)) { if (OB_ISNULL(raw_expr)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("Get unexpected null", K(ret)); LOG_WARN("Get unexpected null", K(ret));
} else if (!raw_expr->has_flag(IS_COLUMNLIZED)) { } else if (raw_expr->has_flag(IS_CONST) || raw_expr->has_flag(IS_CONST_EXPR)) {
if (raw_expr->has_flag(IS_CONST) || raw_expr->has_flag(IS_CONST_EXPR)) { skip = true;
skip = true; LOG_TRACE("skip const expr", K(*raw_expr), K(cell_idx));
} else { }
if (OB_SUCC(ret) && !skip) {
if (!raw_expr->has_flag(IS_COLUMNLIZED)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("param expr should have be columnlized", K(*raw_expr)); LOG_ERROR("param expr should have be columnlized", K(*raw_expr));
} else if (OB_FAIL(idx_provider.get_idx(raw_expr, cell_idx))) {
LOG_ERROR("partition by expr should have be columnlized", K(ret), K(*raw_expr));
} }
} else if (OB_FAIL(idx_provider.get_idx(raw_expr, cell_idx))) {
LOG_ERROR("partition by expr should have be columnlized", K(ret), K(*raw_expr));
} else { /* do nothing. */
} }
return ret; return ret;
} }
......
...@@ -119,7 +119,7 @@ int ObExprGeneratorImpl::generate_infix_expr(ObRawExpr& raw_expr) ...@@ -119,7 +119,7 @@ int ObExprGeneratorImpl::generate_infix_expr(ObRawExpr& raw_expr)
sql_expr_->start_gen_infix_exr(); sql_expr_->start_gen_infix_exr();
auto& exprs = sql_expr_->get_infix_expr().get_exprs(); auto& exprs = sql_expr_->get_infix_expr().get_exprs();
if (OB_FAIL(raw_expr.do_visit(*this))) { if (OB_FAIL(raw_expr.do_visit(*this))) {
LOG_WARN("expr visit failed", K(ret)); LOG_WARN("expr visit failed", K(ret), K(raw_expr));
} else if (exprs.count() > 1) { } else if (exprs.count() > 1) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("should add one expr per visit", K(ret), K(raw_expr)); LOG_WARN("should add one expr per visit", K(ret), K(raw_expr));
...@@ -1299,6 +1299,7 @@ int ObExprGeneratorImpl::visit(ObCaseOpRawExpr& expr) ...@@ -1299,6 +1299,7 @@ int ObExprGeneratorImpl::visit(ObCaseOpRawExpr& expr)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObPostExprItem item; ObPostExprItem item;
bool need_calc = true;
item.set_accuracy(expr.get_accuracy()); item.set_accuracy(expr.get_accuracy());
if (OB_ISNULL(sql_expr_)) { if (OB_ISNULL(sql_expr_)) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
...@@ -1306,14 +1307,26 @@ int ObExprGeneratorImpl::visit(ObCaseOpRawExpr& expr) ...@@ -1306,14 +1307,26 @@ int ObExprGeneratorImpl::visit(ObCaseOpRawExpr& expr)
} else if (expr.has_flag(IS_COLUMNLIZED)) { } else if (expr.has_flag(IS_COLUMNLIZED)) {
int64_t idx = OB_INVALID_INDEX; int64_t idx = OB_INVALID_INDEX;
if (OB_FAIL(column_idx_provider_.get_idx(&expr, idx))) { if (OB_FAIL(column_idx_provider_.get_idx(&expr, idx))) {
LOG_WARN("get index failed", K(ret)); // if an expr has been marked with IS_COLUMNLIZED but get invalid idx,
// then it most likely be a const shared expr and need to calculate again
if (ret == OB_ENTRY_NOT_EXIST && idx == OB_INVALID_INDEX &&
(expr.has_flag(IS_CONST) || expr.has_flag(IS_CONST_EXPR))) {
ret = OB_SUCCESS;
expr.clear_flag(IS_COLUMNLIZED);
LOG_TRACE("need to recalculate const expr", K(expr));
} else if (ret != OB_ENTRY_NOT_EXIST) {
LOG_WARN("get index failed", K(ret), K(expr), K(idx));
}
} else if (OB_FAIL(item.set_column(idx))) { } else if (OB_FAIL(item.set_column(idx))) {
LOG_WARN("failed to set column", K(ret), K(expr)); LOG_WARN("failed to set column", K(ret), K(expr));
} else if (OB_FAIL(sql_expr_->add_expr_item(item, &expr))) { } else if (OB_FAIL(sql_expr_->add_expr_item(item, &expr))) {
LOG_WARN("failed to add expr item", K(ret)); LOG_WARN("failed to add expr item", K(ret));
} else {
need_calc = false;
} }
} else { }
ObExprOperator* op = NULL; if (OB_SUCC(ret) && need_calc) {
ObExprOperator *op = NULL;
if (OB_FAIL(factory_.alloc(expr.get_expr_type(), op))) { if (OB_FAIL(factory_.alloc(expr.get_expr_type(), op))) {
LOG_WARN("fail to alloc expr_op", K(ret)); LOG_WARN("fail to alloc expr_op", K(ret));
} else if (OB_UNLIKELY(NULL == op)) { } else if (OB_UNLIKELY(NULL == op)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册