cp bug fix to open source branch

This commit is contained in:
obdev
2021-07-20 17:06:14 +08:00
committed by wangzelin.wzl
parent 91bb0da2ae
commit f45d2cdbe2
37 changed files with 766 additions and 628 deletions

View File

@ -3456,7 +3456,45 @@ int Bound::replace_expr(const common::ObIArray<ObRawExpr*>& other_exprs, const c
return ret;
}
int ObFrame::assign(const ObFrame& other)
bool Bound::same_as(const Bound &other, ObExprEqualCheckContext *check_context) const
{
bool bret = true;
if (type_ != other.type_ ||
is_preceding_ != other.is_preceding_ ||
is_nmb_literal_ != other.is_nmb_literal_) {
bret = false;
}
if (bret) {
if ((interval_expr_ == NULL && other.interval_expr_ == NULL) ||
(interval_expr_ != NULL && other.interval_expr_ != NULL &&
interval_expr_->same_as(*(other.interval_expr_), check_context))) {
bret = true;
} else {
bret = false;
}
}
if (bret) {
if ((date_unit_expr_ == NULL && other.date_unit_expr_ == NULL) ||
(date_unit_expr_ != NULL && other.date_unit_expr_ != NULL &&
date_unit_expr_->same_as(*(other.date_unit_expr_), check_context))) {
bret = true;
} else {
bret = false;
}
}
for (int64_t i = 0; bret && i < BOUND_EXPR_MAX; ++i) {
if ((exprs_[i] == NULL && other.exprs_[i] == NULL) ||
(exprs_[i] != NULL && other.exprs_[i] != NULL &&
exprs_[i]->same_as(*(other.exprs_[i]), check_context))) {
bret = true;
} else {
bret = false;
}
}
return bret;
}
int ObFrame::assign(const ObFrame &other)
{
int ret = OB_SUCCESS;
if (OB_LIKELY(this != &other)) {
@ -3600,8 +3638,10 @@ bool ObWinFunRawExpr::same_as(const ObRawExpr& expr, ObExprEqualCheckContext* ch
bool bret = false;
if (expr.is_win_func_expr()) {
bret = true;
const ObWinFunRawExpr& other_ma = static_cast<const ObWinFunRawExpr&>(expr);
if (other_ma.get_func_type() != get_func_type()) {
const ObWinFunRawExpr &other_ma = static_cast<const ObWinFunRawExpr&>(expr);
if (other_ma.get_func_type() != get_func_type() ||
other_ma.get_window_type() != get_window_type() ||
other_ma.is_between() != is_between()) {
bret = false;
// Because name window will construct a window function of count(1) over,
// here we need to compare the name of name Windows
@ -3621,22 +3661,43 @@ bool ObWinFunRawExpr::same_as(const ObRawExpr& expr, ObExprEqualCheckContext* ch
} else { /* do nothing. */
}
if (bret &&
(other_ma.get_param_count() != get_param_count() || other_ma.func_params_.count() != func_params_.count() ||
other_ma.partition_exprs_.count() != partition_exprs_.count() ||
other_ma.order_items_.count() != order_items_.count())) {
if (!bret) {
} else if (other_ma.get_param_count() != get_param_count()
|| other_ma.func_params_.count() != func_params_.count()
|| other_ma.partition_exprs_.count() != partition_exprs_.count()
|| other_ma.order_items_.count() != order_items_.count()
|| !other_ma.upper_.same_as(upper_, check_context)
|| !other_ma.lower_.same_as(lower_, check_context)) {
bret = false;
} else {
for (int64_t i = 0; bret && i < other_ma.get_param_count(); ++i) {
if (OB_ISNULL(other_ma.get_param_expr(i)) || OB_ISNULL(get_param_expr(i))) {
bret = false;
if (bret) {
if ((agg_expr_ == NULL && other_ma.agg_expr_ == NULL) ||
(agg_expr_ != NULL && other_ma.agg_expr_ != NULL &&
agg_expr_->same_as(*other_ma.agg_expr_, check_context))) {
bret = true;
} else {
bret = get_param_expr(i)->same_as(*(other_ma.get_param_expr(i)), check_context);
bret = false;
}
}
for (int64_t i = 0; bret && i < other_ma.func_params_.count(); ++i) {
if (other_ma.func_params_.at(i) == NULL || func_params_.at(i) == NULL ||
!other_ma.func_params_.at(i)->same_as(*func_params_.at(i), check_context)) {
bret = false;
}
}
for (int64_t i = 0; bret && i < other_ma.partition_exprs_.count(); ++i) {
if (other_ma.partition_exprs_.at(i) == NULL || partition_exprs_.at(i) == NULL ||
!other_ma.partition_exprs_.at(i)->same_as(*partition_exprs_.at(i), check_context)) {
bret = false;
}
}
for (int64_t i = 0; bret && i < other_ma.order_items_.count(); ++i) {
if (other_ma.order_items_.at(i).order_type_ != order_items_.at(i).order_type_) {
bret = false;
} else if (other_ma.order_items_.at(i).expr_ == NULL || order_items_.at(i).expr_ == NULL ||
!other_ma.order_items_.at(i).expr_->same_as(*order_items_.at(i).expr_,
check_context)) {
bret = false;
}
}
}

View File

@ -3596,6 +3596,8 @@ public:
virtual int replace_expr(
const common::ObIArray<ObRawExpr*>& other_exprs, const common::ObIArray<ObRawExpr*>& new_exprs);
bool same_as(const Bound &other, ObExprEqualCheckContext *check_context) const;
BoundType type_;
bool is_preceding_;
bool is_nmb_literal_;
@ -3628,11 +3630,11 @@ public:
{
lower_ = lower;
}
inline WindowType get_window_type()
inline WindowType get_window_type() const
{
return win_type_;
}
inline bool is_between()
inline bool is_between() const
{
return is_between_;
}

View File

@ -2579,9 +2579,11 @@ int ObRawExprResolverImpl::process_agg_node(const ParseNode* node, ObRawExpr*& e
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid node children", K(node->num_child_));
} else {
ctx_.parents_expr_info_.add_member(IS_AGG);
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
AggNestedCheckerGuard agg_guard(ctx_);
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
LOG_WARN("failed to add member", K(ret));
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
LOG_WARN("failed to check agg nested.", K(ret));
} else if (T_FUN_COUNT == node->type_ && 1 == node->num_child_) {
if (OB_UNLIKELY(T_STAR != node->children_[0]->type_)) {
@ -2692,11 +2694,12 @@ int ObRawExprResolverImpl::process_agg_node(const ParseNode* node, ObRawExpr*& e
// add invalid table bit index, avoid aggregate function expressions are used as filters
if (OB_FAIL(agg_expr->get_relation_ids().add_member(0))) {
LOG_WARN("failed to add member", K(ret));
} else if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
LOG_WARN("failed to del member", K(ret));
} else {
expr = agg_expr;
}
}
ctx_.parents_expr_info_.del_member(IS_AGG);
}
// set the expr in nested agg.
if (OB_SUCC(ret) && is_in_nested_aggr) {
@ -2726,10 +2729,12 @@ int ObRawExprResolverImpl::process_group_aggr_node(const ParseNode* node, ObRawE
ret = OB_ERR_UNEXPECTED;
LOG_WARN("inalid group concat node", K(ret), K(node->children_));
} else {
ctx_.parents_expr_info_.add_member(IS_AGG);
ParseNode* expr_list_node = node->children_[1];
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
ParseNode *expr_list_node = node->children_[1];
AggNestedCheckerGuard agg_guard(ctx_);
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
LOG_WARN("failed to add member", K(ret));
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
LOG_WARN("failed to check agg nested.", K(ret));
} else if (share::is_mysql_mode() && is_in_nested_aggr) {
ret = OB_ERR_INVALID_GROUP_FUNC_USE;
@ -2810,8 +2815,11 @@ int ObRawExprResolverImpl::process_group_aggr_node(const ParseNode* node, ObRawE
}
}
if (OB_SUCC(ret)) {
ctx_.parents_expr_info_.del_member(IS_AGG);
expr = agg_expr;
if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
LOG_WARN("failed to del member", K(ret));
} else {
expr = agg_expr;
}
}
}
if (OB_SUCC(ret) && is_in_nested_aggr) {
@ -2847,9 +2855,11 @@ int ObRawExprResolverImpl::process_keep_aggr_node(const ParseNode* node, ObRawEx
ret = OB_ERR_UNEXPECTED;
LOG_WARN("inalid group concat node", K(ret), K(node->children_));
} else {
ctx_.parents_expr_info_.add_member(IS_AGG);
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
AggNestedCheckerGuard agg_guard(ctx_);
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
LOG_WARN("failed to add member", K(ret));
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
LOG_WARN("failed to check agg nested.", K(ret));
} else if (NULL != node->children_[0] && T_DISTINCT == node->children_[0]->type_) {
ret = OB_DISTINCT_NOT_ALLOWED;
@ -2897,8 +2907,11 @@ int ObRawExprResolverImpl::process_keep_aggr_node(const ParseNode* node, ObRawEx
}
}
if (OB_SUCC(ret)) {
ctx_.parents_expr_info_.del_member(IS_AGG);
expr = agg_expr;
if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
LOG_WARN("failed to del member", K(ret));
} else {
expr = agg_expr;
}
}
}
if (OB_SUCC(ret) && is_in_nested_aggr) {
@ -4345,14 +4358,17 @@ int ObRawExprResolverImpl::check_and_canonicalize_window_expr(ObRawExpr* expr)
}
}
if (OB_SUCC(ret) && share::is_mysql_mode() && w_expr->has_frame_orig() &&
WINDOW_RANGE == win_type && 0 == order_items.count()) {
ret = OB_ERR_MISS_ORDER_BY_EXPR;
LOG_WARN("missing ORDER BY expression in the window specification", K(ret));
}
// reset frame
if (OB_SUCC(ret)) {
if (0 == order_items.count() ||
(ObRawExprResolverImpl::should_not_contain_window_clause(func_type) && win_type != WINDOW_MAX)) {
win_type = WINDOW_MAX;
upper = Bound();
lower = Bound();
}
if (OB_SUCC(ret) && win_type != WINDOW_MAX && should_not_contain_window_clause(func_type)) {
win_type = WINDOW_MAX;
upper = Bound();
lower = Bound();
}
if (OB_SUCC(ret)) {
@ -4641,7 +4657,10 @@ int ObRawExprResolverImpl::process_agg_udf_node(
ctx_.parents_expr_info_.add_member(IS_AGG);
AggNestedCheckerGuard agg_guard(ctx_);
bool is_in_nested_aggr = false;
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
LOG_WARN("failed to add member", K(ret));
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
LOG_WARN("failed to check agg nested.", K(ret));
} else if (is_in_nested_aggr) {
ret = OB_ERR_INVALID_GROUP_FUNC_USE;
@ -4673,13 +4692,12 @@ int ObRawExprResolverImpl::process_agg_udf_node(
// add invalid table bit index, avoid aggregate function expressions are used as filters
if (OB_FAIL(agg_expr->get_relation_ids().add_member(0))) {
LOG_WARN("failed to add member", K(ret));
} else if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
LOG_WARN("failed to del member", K(ret));
} else {
expr = agg_expr;
}
}
// FIXME WHY?
ctx_.parents_expr_info_.del_member(IS_AGG);
return ret;
}

View File

@ -2063,6 +2063,7 @@ int ObRawExprUtils::copy_expr(ObRawExprFactory& expr_factory, const ObRawExpr* o
int ret = OB_SUCCESS;
bool need_copy = true;
bool copy_share_expr = (COPY_REF_SHARED == copy_types) || use_new_allocator;
bool is_stack_overflow = false;
if (NULL == origin) {
need_copy = false;
dest = NULL;
@ -2076,7 +2077,13 @@ int ObRawExprUtils::copy_expr(ObRawExprFactory& expr_factory, const ObRawExpr* o
need_copy = false;
}
if (OB_SUCC(ret) && need_copy) {
if (OB_FAIL(ret) || !need_copy) {
} else if (OB_FAIL(check_stack_overflow(is_stack_overflow))) {
LOG_WARN("check stack overflow failed", K(ret));
} else if (is_stack_overflow) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("too deep recursive", K(ret));
} else {
// deep copy here
ObRawExpr::ExprClass expr_class = origin->get_expr_class();
switch (expr_class) {