Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Date: 2021-02-25 02:17:09
Message-ID: YDcIpSa8c+Lrm9m6@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 25, 2021 at 10:30:41AM +0900, Michael Paquier wrote:
> Your patch does not have a test for that, but it fixes the list
> handling. With more nested levels and some UNIONs, the patch I sent
> previously would equally break, though I am not sure we need more than
> what I am sending here. What do you think about this extra test?

By the way, here is a fancier test case to make the list handling
recurse much more in checkWellFormedRecursionWalker():
WITH RECURSIVE outermost(x) AS (
SELECT 1
UNION (WITH innermost1 AS (
SELECT 2
UNION (WITH innermost2 AS (
SELECT 3
UNION (WITH innermost3 AS (
SELECT 4
UNION (WITH innermost4 AS (
SELECT 5
UNION (WITH innermost5 AS (SELECT 6)
SELECT * FROM innermost5))
SELECT * FROM innermost4))
SELECT * FROM innermost3))
SELECT * FROM innermost2))
SELECT * FROM outermost
UNION SELECT * FROM innermost1)
)
SELECT * FROM outermost ORDER BY 1;
--
Michael

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2021-02-25 02:30:36 Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Previous Message Tom Lane 2021-02-25 02:13:46 Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs