BUG #19626: Segmentation fault planning self-join IN subquery with LATERAL UNION ALL - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19626: Segmentation fault planning self-join IN subquery with LATERAL UNION ALL
Date
Msg-id 19626-f1b794ea5ad205e9@postgresql.org
Whole thread
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19626
Logged by:          Suyang Zhong
Email address:      syzhong16@gmail.com
PostgreSQL version: 19beta3
Operating system:   Ubuntu 22.04
Description:

Hi,

The following test case caused a segmentation fault.

```
CREATE TABLE t0(c2 INT PRIMARY KEY, c3 INT);

SELECT count(*) FROM t0
INNER JOIN LATERAL (SELECT t0.c3 UNION ALL SELECT t0.c3) AS s ON (s.c3 IS
NOT NULL)
WHERE t0.c2 IN (SELECT c2 FROM t0);
-- server closed the connection unexpectedly
```

Here's the log on the server side.

```
2026-08-18 02:50:27.936 UTC [530] STATEMENT:  CREATE TABLE t0(c2 INT PRIMARY
KEY, c3 INT);
2026-08-18 02:50:32.126 UTC [1] LOG:  client backend (PID 530) was
terminated by signal 11: Segmentation fault
2026-08-18 02:50:32.126 UTC [1] DETAIL:  Failed process was running: SELECT
count(*) FROM t0
        INNER JOIN LATERAL (SELECT t0.c3 UNION ALL SELECT t0.c3) AS s ON
(s.c3 IS NOT NULL)
        WHERE t0.c2 IN (SELECT c2 FROM t0);
2026-08-18 02:50:32.126 UTC [1] LOG:  terminating any other active server
processes
2026-08-18 02:50:32.128 UTC [1] LOG:  all server processes terminated;
reinitializing
2026-08-18 02:50:32.143 UTC [534] LOG:  database system was interrupted;
last known up at 2026-08-18 01:27:03 UTC
```

Reproduced on 20devel and 19beta3.





pgsql-bugs by date:

Previous
From: "zengman"
Date:
Subject: Re:BUG #19625: SQL/JSON boolean DEFAULT expression silently replaced with 'false'
Next
From: Andrey Rachitskiy
Date:
Subject: Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY