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 1xD7g2-00000000KQu-2bYG for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Oct 2026 21:53:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xD7g0-00000003QL1-0Y7J for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Oct 2026 21:53:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xD7fz-00000003QKt-3gos for pgsql-bugs@lists.postgresql.org; Sat, 03 Oct 2026 21:53:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xD7fx-00000000DWB-3pbv for pgsql-bugs@lists.postgresql.org; Sat, 03 Oct 2026 21:53:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 693LrmUN261147; Sat, 3 Oct 2026 17:53:48 -0400 From: Tom Lane To: feasiblechart@gmail.com cc: David Rowley , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19742: `INTERSECT` under a `UNION ALL` with an empty arm fails with "could not find pathkey item t" In-reply-to: <19742-dc403ca277cad1d3@postgresql.org> References: <19742-dc403ca277cad1d3@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sat, 03 Oct 2026 16:17:03 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <261145.1791064428.1@sss.pgh.pa.us> Date: Sat, 03 Oct 2026 17:53:48 -0400 Message-ID: <261146.1791064428@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > Please see the repro. Seems like a regression; 19beta4 and the current main > branch both have this error raised, but 18.6 works fine. I ran it with psql > CREATE TABLE d (a int); > INSERT INTO d VALUES (1), (1), (2), (NULL), (3); > SELECT * FROM (SELECT a FROM d INTERSECT ALL SELECT a FROM d > UNION ALL SELECT a FROM d WHERE false) s > WHERE a = 1; > -- ERROR: XX000: could not find pathkey item to sort Bisecting shows this started with fdda78e361f136ec2b8de579b366c1e66bba1199 is the first bad commit commit fdda78e361f136ec2b8de579b366c1e66bba1199 Author: David Rowley Date: Wed Nov 5 11:48:09 2025 +1300 Fix possible usage of incorrect UPPERREL_SETOP RelOptInfo 03d40e4b5 allowed dummy UNION [ALL] children to be removed from the plan by checking for is_dummy_rel(). That commit neglected to still account for the relids from the dummy rel so that the correct UPPERREL_SETOP RelOptInfo could be found and used for adding the Paths to. I suspect that that commit just allowed reaching some pre-existing mistake, but I've not dug into it. regards, tom lane