fix connect by level cannot be pushed down

This commit is contained in:
obdev
2023-09-14 05:18:03 +00:00
committed by ob-robot
parent 2bf2d711da
commit 53824d0e67
2 changed files with 18 additions and 9 deletions

View File

@ -342,7 +342,14 @@ int ObNLConnectByWithIndexOp::prepare_rescan_params()
int ObNLConnectByWithIndexOp::read_pump_func_going()
{
int ret = OB_SUCCESS;
if (OB_LIKELY(!MY_SPEC.rescan_params_.empty())) {
if (OB_FAIL(set_level_as_param(connect_by_pump_.get_current_level()))) {
/* LEVEL is allowed to be a dynamic param, so it needs to be set before
* preparing rescan params.
* set_level_as_param is currently repeatedly called in multiple places,
* which does not make sense and can be optimized later.
*/
LOG_WARN("failed to set current level", K(ret));
} else if (OB_LIKELY(!MY_SPEC.rescan_params_.empty())) {
if (OB_FAIL(prepare_rescan_params())) {
LOG_WARN("failed to prepare rescan params", K(ret));
} else if (OB_FAIL(right_->rescan())) {

View File

@ -10571,7 +10571,9 @@ public:
if (OB_ISNULL(old_expr) || OB_ISNULL(left_table_set_) || OB_ISNULL(copier_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("params are invalid", K(ret), K(old_expr), K(left_table_set_));
} else if (!old_expr->get_relation_ids().overlap(*left_table_set_)) {
} else if (!old_expr->get_relation_ids().overlap(*left_table_set_) &&
!old_expr->has_flag(CNT_LEVEL) &&
!old_expr->has_flag(CNT_PRIOR)) {
new_expr = old_expr;
} else if (old_expr->is_query_ref_expr()) {
// only function table subquery expr may come into here
@ -10612,8 +10614,10 @@ public:
new_expr = new_query_ref;
} else if (copier_->is_existed(old_expr)) {
// do nothing
} else if (old_expr->is_column_ref_expr() &&
old_expr->get_relation_ids().is_subset(*left_table_set_)) {
} else if ((old_expr->is_column_ref_expr() &&
old_expr->get_relation_ids().is_subset(*left_table_set_))
|| old_expr->has_flag(IS_LEVEL)
|| old_expr->has_flag(IS_PRIOR)) {
new_expr = old_expr;
if (OB_FAIL(ObRawExprUtils::create_new_exec_param(query_ctx_,
expr_factory,
@ -13565,12 +13569,10 @@ int ObJoinOrder::extract_pushdown_quals(const ObIArray<ObRawExpr *> &quals,
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(qual), K(ret));
// can not push down expr with subquery
} else if (qual->has_flag(CNT_PSEUDO_COLUMN) ||
qual->has_flag(CNT_PRIOR) ||
qual->has_flag(CNT_ROWNUM)) {
} else if (qual->has_flag(CNT_ROWNUM)) {
if (force_inner_nl && qual->has_flag(CNT_SUB_QUERY)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("can not push down special qual", KPC(qual), K(ret));
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "join condition contains rownum and subquery");
}
} else if (T_OP_NE == qual->get_expr_type() &&
!force_inner_nl) {