Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 10215501441(at)stu(dot)ecnu(dot)edu(dot)cn
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19653: "variable not found in subplan target list" during planning with parallel parameterized nested loop,
Date: 2026-09-04 15:27:11
Message-ID: 1570204.1788535631@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
>> A query using a partitioned left/right join split, with
>> `enable_partitionwise_join`, parallel settings, and `GROUP BY ROLLUP` fails
>> at planning time with:
>> ERROR: variable not found in subplan target list

> Fascinating. For me, this fails *only* in v18, not earlier or later
> branches. That's not a usual pattern for our bugs ...

A bit of quality time with "git bisect" found that the misbehavior
started at

cc5d98525d43c22b98f360ef0f2c8d7dc57f04dc is the first bad commit
commit cc5d98525d43c22b98f360ef0f2c8d7dc57f04dc
Author: Richard Guo <rguo(at)postgresql(dot)org>
Date: Thu Mar 13 16:36:03 2025 +0900

Fix incorrect handling of subquery pullup

and was fixed by

014f9a831a320666bf2195949f41710f970c54ad is the first new commit
commit 014f9a831a320666bf2195949f41710f970c54ad
Author: Robert Haas <rhaas(at)postgresql(dot)org>
Date: Fri Dec 5 11:05:12 2025 -0500

Don't reset the pathlist of partitioned joinrels.

The proximate cause of the failure is that we have a NestLoopParam
containing a Var, which we need to find in the tlist of the nestloop's
outer relation, but what is in the tlist is a PlaceHolderVar wrapping
that Var. So it's possible to see some connection to cc5d98525, but
it seems entirely accidental that 014f9a831 fixed it. I bet there
are related cases that are still broken.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2026-09-04 15:54:17 Re: BUG #19644: byteaout, float8out and float4out are marked IMMUTABLE but depend on GUCs
Previous Message Andrei Lepikhov 2026-09-04 15:12:20 Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col