Disallow joins between nested RECURSIVE clauses
Joining nested REURSIVE clauses is planned as a join between two WorkTableScan nodes, which we currently cannot do. Detect and disallow for now until we have the required infrastructure to handle this class of queries. The below query is an example of this: WITH RECURSIVE r1 AS ( SELECT 1 AS a UNION ALL ( WITH RECURSIVE r2 AS ( SELECT 2 as b UNION ALL SELECT b FROM r1, r2 ) SELECT b FROM r2 ) ) SELECT * FROM r1 LIMIT 1; In upstream PostgreSQL, the resulting plan exhibits the same behavior as in GPDB, but there is no restiction on WorkTableScan on the inner side of joins in PostgreSQL: QUERY PLAN ------------------------------------------------------------- Limit CTE r1 -> Recursive Union -> Result -> CTE Scan on r2 r2_1 CTE r2 -> Recursive Union -> Result -> Nested Loop -> WorkTable Scan on r1 r1_1 -> WorkTable Scan on r2 -> CTE Scan on r1 (12 rows) Backported from master commit e9c0e77a
Showing
想要评论请 注册 或 登录