pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19883: Partition pruning errors on SubPlan inside = ANY array
2+ messages / 2 participants
[nested] [flat]

* BUG #19883: Partition pruning errors on SubPlan inside = ANY array
@ 2026-11-11 14:04 PG Bug reporting form <noreply@postgresql.org>
  2026-11-12 20:19 ` Re: BUG #19883: Partition pruning errors on SubPlan inside = ANY array Andrey Rachitskiy <pl0h0yp1@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2026-11-11 14:04 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: imchifan@163.com

The following bug has been logged on the website:

Bug reference:      19883
Logged by:          Qifan Liu
Email address:      imchifan@163.com
PostgreSQL version: 18.6
Operating system:   Linux/amd64
Description:        

On PostgreSQL 18.6 on Linux/amd64, a SELECT against a range-partitioned
table fails with `ERROR: SubPlan found with no parent plan` when an `= ANY`
array element contains an uncorrelated SubPlan whose expression evaluates to
NULL.

The predicate is valid SQL and should return no rows. `NULL::integer IN
(SELECT v ...)` evaluates to NULL, its integer cast remains NULL, and
comparison with the resulting one-element NULL array is not true for either
row. Startup partition pruning should not attempt to evaluate the SubPlan in
a context without a parent PlanState.

How to repeat:

```sql
DROP TABLE IF EXISTS items CASCADE;
DROP TABLE IF EXISTS lookup_values;

CREATE TABLE items (id integer) PARTITION BY RANGE (id);
CREATE TABLE items_low
  PARTITION OF items FOR VALUES FROM (MINVALUE) TO (10);
CREATE TABLE items_high
  PARTITION OF items FOR VALUES FROM (10) TO (MAXVALUE);
INSERT INTO items VALUES (1), (11);

CREATE TABLE lookup_values (v integer);
INSERT INTO lookup_values VALUES (1);

SELECT id
FROM items
WHERE id = ANY
      (ARRAY[(NULL::integer IN
              (SELECT v FROM lookup_values))::integer])
ORDER BY id;

DROP TABLE items CASCADE;
DROP TABLE lookup_values;
```

Save this as `reproducer.sql` and run:

```
psql -X -f reproducer.sql
```

The client reports:

```
ERROR:  SubPlan found with no parent plan
```

The corresponding server log records the failing statement:

```
ERROR:  SubPlan found with no parent plan
STATEMENT:  SELECT id
            FROM items
            WHERE id = ANY
                  (ARRAY[(NULL::integer IN
                          (SELECT v FROM lookup_values))::integer])
            ORDER BY id;
```

Instead, the SELECT should complete normally and return zero rows. The issue
was reproduced on PostgreSQL 18.6; no other versions were tested. This
occurs when startup partition pruning processes an `= ANY` expression whose
array contains an uncorrelated SubPlan that evaluates to NULL.








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19883: Partition pruning errors on SubPlan inside = ANY array
  2026-11-11 14:04 BUG #19883: Partition pruning errors on SubPlan inside = ANY array PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-12 20:19 ` Andrey Rachitskiy <pl0h0yp1@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrey Rachitskiy @ 2026-11-12 20:19 UTC (permalink / raw)
  To: imchifan@163.com; pgsql-bugs@lists.postgresql.org

чт, 12 нояб. 2026 г. в 22:16, PG Bug reporting form <noreply@postgresql.org
>:

>
> On PostgreSQL 18.6 on Linux/amd64, a SELECT against a range-partitioned
> table fails with `ERROR: SubPlan found with no parent plan` when an `= ANY`
> array element contains an uncorrelated SubPlan whose expression evaluates
> to
> NULL.
>
>
Hi Liu,
Fix in master eacee6b6187 (Richard Guo, backpatched to 18). In REL_18_7,
fixed by 70ffc30e12b.
We need to upgrade to 18.7 if possible.


-- 
Regards,
Rachitskiy Andrey

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-11-12 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 14:04 BUG #19883: Partition pruning errors on SubPlan inside = ANY array PG Bug reporting form <noreply@postgresql.org>
2026-11-12 20:19 ` Andrey Rachitskiy <pl0h0yp1@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox