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 1x3Q4A-006Q1s-34 for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Sep 2026 03:30:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3Q49-00Gmhi-0F for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Sep 2026 03:30:41 +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 1x3Q48-00Gmha-2f for pgsql-bugs@lists.postgresql.org; Mon, 07 Sep 2026 03:30:40 +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 1x3Q46-00000003L1v-0qp1 for pgsql-bugs@lists.postgresql.org; Mon, 07 Sep 2026 03:30:40 +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 6873UXLr157317; Sun, 6 Sep 2026 23:30:33 -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> <116500.1788717110@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Mon, 07 Sep 2026 11:00:49 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <157315.1788751833.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 06 Sep 2026 23:30:33 -0400 Message-ID: <157316.1788751833@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Mon, Sep 7, 2026 at 2:51 AM Tom Lane wrote: >> 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? > Yeah, we don't union child relids and parent relids anywhere else, and > I'm not entirely happy with it either. But I'm not sure we can simply > remove the child relids here, because the same set is used for two > different membership tests. For Vars, we check whether var->varno is > a member of the set, and within a child join the Vars carry child > relids. For PlaceHolderVars, we check whether ph_eval_at is a subset > of the set, and ph_eval_at always carries parent relids. So, AFAICS, > the set needs the child relids for the Var test and the parent relids > for the PHV test, and dropping the child relids would break the Var > test. Yeah, I tried adjusting things like that and the regression tests immediately crashed. So now I think we have to do it as you have it; but maybe the comment could be improved to explain that we need to match both Vars having the child relid and PHVs having top-parent relids. (Could there be Vars having the parent relid? Not sure, but if there are, I suppose we'd need to match them too.) > Maybe an alternative is to keep the set in top-parent terms and > translate each Var's varno to its top parent before the membership > test, or to leave the set alone and instead translate ph_eval_at into > child relids before the subset test. But AFAICS we need to update > quite a few places to make either way work, such as > replace_nestloop_params_mutator(), identify_current_nestloop_params(), > process_subquery_nestloop_params(), and maybe more. Not sure if this > is a better option. Agreed. Quite aside from the number of places that'd have to be touched, I'm not too comfortable with rethinking those design decisions in a hasty back-patch. It seems not unlikely that extensions contain code that expects the current data structure definitions. regards, tom lane