Re: BUG #18536: Using WITH inside WITH RECURSIVE triggers a "shouldn't happen" error

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, exclusion(at)gmail(dot)com
Subject: Re: BUG #18536: Using WITH inside WITH RECURSIVE triggers a "shouldn't happen" error
Date: 2024-07-15 12:16:09
Message-ID: CAJ7c6TN+f4duGn2cfHsgMiYUe+9uHek4DsD_a3yV6y2NCq9XCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

> triggers an error:
> ERROR: XX000: missing recursive reference
> LOCATION: checkWellFormedRecursion, parse_cte.c:896

FWIW I couldn't reproduce the reported error on REL_17_STABLE
(b8bf76cbde39). The error I got seems reasonable:

```
46087 (master) =# WITH RECURSIVE t(n) AS (
WITH t1 AS (SELECT 1 FROM t) SELECT 1
UNION
SELECT 1 FROM t1)
SELECT * FROM t;
ERROR: recursive reference to query "t" must not appear within a subquery
LINE 2: WITH t1 AS (SELECT 1 FROM t) SELECT 1
^
```

We should add regression tests though, as v2 does.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Aleksander Alekseev 2024-07-15 12:17:53 Re: BUG #18536: Using WITH inside WITH RECURSIVE triggers a "shouldn't happen" error
Previous Message Aleksander Alekseev 2024-07-15 11:23:03 Re: BUG #18534: ERROR: portal "C_n" does not exist type of error getting thrown.