【bugfixed】解决cte+connect by语句sql执行报错,找不到relation的问题
This commit is contained in:
@ -1280,10 +1280,7 @@ static void AddWithClauseToBranch(ParseState *pstate, SelectStmt *stmt, List *re
|
||||
|
||||
foreach(lc2, clause->ctes) {
|
||||
CommonTableExpr *cte = (CommonTableExpr *)lfirst(lc2);
|
||||
|
||||
if (pg_strcasecmp(cte->ctename, info->relname) == 0) {
|
||||
ctes = lappend(ctes, cte);
|
||||
}
|
||||
ctes = lappend(ctes, cte);
|
||||
}
|
||||
|
||||
foreach(lc2, pstate->p_ctenamespace) {
|
||||
|
@ -628,3 +628,16 @@ reset enable_startwith_debug;
|
||||
LOG: statement: reset enable_startwith_debug;
|
||||
reset client_min_messages;
|
||||
LOG: statement: reset client_min_messages;
|
||||
-- bugfixed I61AIW: cte+connect by error, cannot find relation
|
||||
create table temptest (col numeric(3));
|
||||
insert into temptest values ('1'),('2'),('3'),('4'),('');
|
||||
WITH alias5 AS ( SELECT alias1.col AS alias2 FROM temptest AS alias1 CONNECT BY nocycle alias1.col >= alias1.col ),
|
||||
alias8 AS ( SELECT * FROM alias5 CONNECT BY nocycle PRIOR alias5.alias2 != alias5.alias2)
|
||||
SELECT * FROM alias8, temptest CONNECT BY nocycle PRIOR temptest.col < temptest.col;
|
||||
ERROR: Current Start With...Connect by has exceeded max iteration times 200
|
||||
HINT: Please check your connect by clause carefully
|
||||
WITH alias5 AS ( SELECT alias1.col AS alias2 FROM temptest AS alias1 CONNECT BY nocycle alias1.col >= alias1.col )
|
||||
SELECT * FROM alias5, temptest CONNECT BY nocycle PRIOR temptest.col < temptest.col;
|
||||
ERROR: Current Start With...Connect by has exceeded max iteration times 200
|
||||
HINT: Please check your connect by clause carefully
|
||||
drop table temptest;
|
||||
|
@ -180,3 +180,16 @@ order siblings by id;
|
||||
|
||||
reset enable_startwith_debug;
|
||||
reset client_min_messages;
|
||||
|
||||
-- bugfixed I61AIW: cte+connect by error, cannot find relation
|
||||
create table temptest (col numeric(3));
|
||||
insert into temptest values ('1'),('2'),('3'),('4'),('');
|
||||
|
||||
WITH alias5 AS ( SELECT alias1.col AS alias2 FROM temptest AS alias1 CONNECT BY nocycle alias1.col >= alias1.col ),
|
||||
alias8 AS ( SELECT * FROM alias5 CONNECT BY nocycle PRIOR alias5.alias2 != alias5.alias2)
|
||||
SELECT * FROM alias8, temptest CONNECT BY nocycle PRIOR temptest.col < temptest.col;
|
||||
|
||||
WITH alias5 AS ( SELECT alias1.col AS alias2 FROM temptest AS alias1 CONNECT BY nocycle alias1.col >= alias1.col )
|
||||
SELECT * FROM alias5, temptest CONNECT BY nocycle PRIOR temptest.col < temptest.col;
|
||||
|
||||
drop table temptest;
|
||||
|
Reference in New Issue
Block a user