fix LEVEL in START WITH bug

This commit is contained in:
hy-guo 2024-04-08 05:49:58 +00:00 committed by ob-robot
parent 1facbc67f8
commit f296a63615
2 changed files with 17 additions and 1 deletions

View File

@ -2460,6 +2460,21 @@ int ObRawExprResolverImpl::process_pseudo_column_node(const ParseNode &node, ObR
} else if (OB_UNLIKELY(false == is_pseudo_column_valid_scope(ctx_.current_scope_))) {
ret = OB_ERR_CBY_PSEUDO_COLUMN_NOT_ALLOWED;
LOG_WARN("pseudo column at invalid scope", K(ctx_.current_scope_), K(ret));
} else if (T_START_WITH_SCOPE == ctx_.current_scope_) {
// Oracle supports LEVEL column in START WITH, and the value of LEVEL is 0.
// But, other pseudo columns in START WITH scope are not allowed.
ObConstRawExpr *c_expr = NULL;
if (OB_UNLIKELY(T_LEVEL != pseudo_column_node->type_)) {
ret = OB_ERR_CBY_PSEUDO_COLUMN_NOT_ALLOWED;
LOG_WARN("invalid pseudo column at START WITH scope", K(pseudo_column_node->type_), K(ret));
} else if (OB_FAIL(ObRawExprUtils::build_const_number_expr(ctx_.expr_factory_,
ObObjType::ObNumberType,
number::ObNumber::get_zero(),
c_expr))) {
LOG_WARN("failed to create const number expr", K(ret));
} else {
expr = c_expr;
}
} else if (OB_FAIL(check_pseudo_column_exist(pseudo_column_node->type_, pseudo_column_expr))) {
LOG_WARN("fail to check pseudo column exist", K(ret));
} else if (pseudo_column_expr != NULL) {

View File

@ -305,7 +305,8 @@ inline bool ObRawExprResolverImpl::is_pseudo_column_valid_scope(ObStmtScope scop
|| scope == T_ORDER_SCOPE
|| scope == T_CONNECT_BY_SCOPE
|| scope == T_WITH_CLAUSE_SEARCH_SCOPE
|| scope == T_WITH_CLAUSE_CYCLE_SCOPE;
|| scope == T_WITH_CLAUSE_CYCLE_SCOPE
|| scope == T_START_WITH_SCOPE;
}