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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: syzhong16(at)gmail(dot)com
Subject: BUG #19626: Segmentation fault planning self-join IN subquery with LATERAL UNION ALL
Date: 2026-08-18 03:06:09
Message-ID: 19626-f1b794ea5ad205e9@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19626
Logged by: Suyang Zhong
Email address: syzhong16(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message jian he 2026-08-18 03:47:53 Re: MERGE/SPLIT PARTITIONS issues/questions
Previous Message zengman 2026-08-18 02:06:15 Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY