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.96) (envelope-from ) id 1x3H2B-006HJQ-1N for pgsql-bugs@arkaria.postgresql.org; Sun, 06 Sep 2026 17:52:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3H28-00FJOH-1B for pgsql-bugs@arkaria.postgresql.org; Sun, 06 Sep 2026 17:52:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x3H28-00FJO8-0M for pgsql-bugs@lists.postgresql.org; Sun, 06 Sep 2026 17:52:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x3H24-00000003HId-3DlS for pgsql-bugs@lists.postgresql.org; Sun, 06 Sep 2026 17:51:59 +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 686HpoWk116501; Sun, 6 Sep 2026 13:51:50 -0400 From: Tom Lane To: Richard Guo cc: 10215501441@stu.ecnu.edu.cn, Robert Haas , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop, In-reply-to: References: <19653-9352cc6ba17b662f@postgresql.org> <1564958.1788530496@sss.pgh.pa.us> <1570204.1788535631@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Sat, 05 Sep 2026 22:26:39 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <116499.1788717110.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 06 Sep 2026 13:51:50 -0400 Message-ID: <116500.1788717110@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Sat, Sep 5, 2026 at 8:09 AM Richard Guo wrote: >> It seems to me the root cause is that in a partitionwise child join, >> root->curOuterRels holds child relids, but PlaceHolderInfo.ph_eval_at >> is always expressed in top-parent relids. So in >> replace_nestloop_params_mutator the subset check fails for a PHV >> evaluated at the outer child rel. > The required-outer set passed to identify_current_nestloop_params() > has the same problem. Right. (For anyone following along at home, the new test case fails with "variable not found in subplan target list" if you run it against HEAD. You need to apply the first part of Richard's patch to get to "failed to assign all NestLoopParams to plan nodes".) > Attached is a patch to fix both bugs. Hmm, I'm not enamored of just union'ing the top_parent_relids with the regular relids. I don't see us doing that anywhere else, so it smells like a shortcut. Shouldn't we remove the child relids while adding the parent relids? > (I'm surprised it has taken us so long to find these bugs. I suspect > part of the reason is that partitionwise join is disabled by default. Probably. > AFAICS, enable_partitionwise_join and enable_partitionwise_aggregate > are the only planner method GUCs that are off by default. I wonder if > we should turn them on by default, so that bugs in these areas get > found sooner.) I've not paid close attention to that stuff, but I had the impression that it is disabled-by-default because it adds materially to planning time and we don't trust the associated cost estimates too much. Robert might have a better-informed opinion though. regards, tom lane