Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2021-02-25T02:13:46Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> writes: > Yes, thanks. While looking at that this morning, I have been able to > get a crash with my previous patch once I used more nesting in those > CTEs and your test is much simpler. I also got a test case able to > break things the same way in checkWellFormedRecursionWalker(): > WITH RECURSIVE outermost(x) AS ( > SELECT 1 > UNION (WITH innermost as (WITH innermost2 AS (SELECT 2) SELECT * FROM innermost2) > SELECT * FROM outermost > UNION SELECT * FROM innermost) > ) > SELECT * FROM outermost ORDER BY 1; Hmm, I don't see any failure from that... In my understanding of the bug, you need at least half a dozen levels of WITH nesting to provoke a problem, because nothing will go wrong until the innerwiths list gets to be six entries long, causing list.c to move its elements array to somewhere else. If it is possible to fail without that then there's still something here that I don't get. regards, tom lane
Commits
-
Fix list-manipulation bug in WITH RECURSIVE processing.
- 80ca8464fe02 14.0 landed
- 49076fd3ba6b 13.3 landed