!1597 修复startwitch下cte和subquery嵌套的问题

Merge pull request !1597 from 杨皓/master
This commit is contained in:
opengauss-bot
2022-03-17 03:58:55 +00:00
committed by Gitee
3 changed files with 20 additions and 0 deletions

View File

@ -331,6 +331,11 @@ void AddStartWithTargetRelInfo(ParseState* pstate, Node* relNode,
startInfo->aliasname = sub->alias->aliasname;
}
SelectStmt *substmt = (SelectStmt*)sub->subquery;
if (substmt->withClause == NULL) {
substmt->withClause = (WithClause*)copyObject(pstate->origin_with);
}
startInfo->rte = rte;
startInfo->rtr = rtr;
startInfo->rtekind = rte->rtekind;

View File

@ -1415,3 +1415,13 @@ LIMIT 169;
----
(0 rows)
create table t123(id int, lid int, name text);
insert into t123 values(1,null,'A'),(2,1,'B'),(3,2,'C');
with t2 as (select * from t123 where id!=10) select level,t.* from (select * from t2 where id!=10 order by id) t start with t.id=2 connect by prior t.id=t.lid;
level | id | lid | name
-------+----+-----+------
1 | 2 | 1 | B
2 | 3 | 2 | C
(2 rows)
drop table t123;

View File

@ -501,3 +501,8 @@ WHERE true CONNECT BY EXISTS (
test_hcb_ptb as ref_7
)
LIMIT 169;
create table t123(id int, lid int, name text);
insert into t123 values(1,null,'A'),(2,1,'B'),(3,2,'C');
with t2 as (select * from t123 where id!=10) select level,t.* from (select * from t2 where id!=10 order by id) t start with t.id=2 connect by prior t.id=t.lid;
drop table t123;