Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRYdt-000000014up-24Gx for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:21 +0000 Received: from localhost ([127.0.0.1]:47716 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRYds-0000000450q-0gWy for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:55046) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR8wo-0000000BSRj-132K for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:05:10 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR8wl-00000000Tdc-1wpG for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:05:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=RkCEWzFRhP4A2igYQXO9JeSHrOJwAlL9UeHtq9GohUE=; b=jDrbfKeTlvt4Sd5kqokTIsSXd/ gVpv5x5bHTd8ODQ9m0jpPiraccSQqdaDD5YWMe0lEhN/kuHNlPXof467nm3/bHvZ9J+s7Do6Ug5G0 BBd4AxusfI3mjYVkWgacKqdPWqtOfehTHurTYDnohB3Nim+66cODrds8mJ1NenFMcXdRmrYO2b0me PILSPCIDD/BYuJ/dRzF2onVF8ooUfIEzPjfKARA8yXeguQ+AJrbTqAUviY7xAkFTGSMdSRgoI9VUc gHzZq1FlIWfu8dVKNakAfmznzIHIkYeEDtR5er5oGOijFnfNHQfe+bBN1L1v2Ajwbl/YgR8dIUyKl QkM9ecbA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR8wi-000000013TG-3LIb for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:05:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR8wh-00000002jrV-3F0v for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:05:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19883: Partition pruning errors on SubPlan inside = ANY array To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: imchifan@163.com Reply-To: imchifan@163.com, pgsql-bugs@lists.postgresql.org Date: Wed, 11 Nov 2026 14:04:19 +0000 Message-ID: <19883-5fe20b9d0ae341dc@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: =20 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 `=3D AN= Y` 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 =3D 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 =3D 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 `=3D ANY` expression who= se array contains an uncorrelated SubPlan that evaluates to NULL.