Re: "variable not found in subplan target lists" with partitionwise join

From: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: "variable not found in subplan target lists" with partitionwise join
Date: 2026-10-19 08:14:18
Message-ID: CAGjGUALYYzxrWM8gC=Yo2b3iEqfxzWei0PXQCamy1YyFXp_C7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Richard,
The fix looks reasonable to me. Checking em_relids for parent members
prevents an untranslated parent expression from being selected for a child
relation, while preserving the existing behavior when relids is NULL. I
reproduced the reported error on a local 20devel build based on 1863452.
After applying the core change and adding the regression case, the query
produces the expected plan and results, and the partition_join regression
test passes. I haven't tested the back branches.
One minor wording suggestion: the new comment says that equal() compares
PlaceHolderVars “only by phid”, but phlevelsup and phnullingrels are also
compared. The relevant point here is that phexpr and phrels are ignored, so
perhaps:
* otherwise match the translated ones in "exprs", since equal()
* ignores phexpr and phrels when comparing PlaceHolderVars.
What do you think?

Thanks!

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-10-19 08:18:49 Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)
Previous Message Chao Li 2026-10-19 08:12:06 Re: DOCS - CREATE PUBLICATION wording re 'ONLY' for partitioned tables.