Re: BUG #19804: "variable not found in subplan target list", DISTINCT agg over Gather`

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: alpkeles99(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19804: "variable not found in subplan target list", DISTINCT agg over Gather`
Date: 2026-11-09 04:41:39
Message-ID: CAHewXNn3dOxH9qf9yJrdrbBVxRy=kDMFjwdZ+vZOK6=q-_PUzQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

Tender Wang <tndrwang(at)gmail(dot)com> 于2026年10月30日周五 16:08写道:
>
> This has become a larger change than I expected, so I am sending it as
> WIP to get feedback.
>

Attached is v2.

The main change in this version fixes the compiler warnings reported
by CI for non-assert builds.
The variables nodenumsortkeys, nodeCollations, and nodeNullsFirst were
assigned only for use in Assert() calls, so they became unused when
assertions were compiled out.
I removed those assertion-only variables. create_append_plan() now
uses an explicit first_subplan flag when it needs information from the
first child.

I also adjusted the sort-column handling so that the common sortColIdx
chosen from the parent Append/MergeAppend targetlist is retained and
checked against every child, including the first one.
For MergeAppend, the first actual child still supplies the comparator
metadata the executor needs, but it no longer replaces the
parent-selected column layout.

The other changes are minor cleanup and formatting.

--
Thanks,
Tender Wang

Attachment Content-Type Size
v2-0001-WIP-Supply-valid-input-Vars-for-sort-EC-selection.patch text/plain 37.5 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-11-09 04:41:40 Re: Correction: 17.11/18.6 slot_getsomeattrs_int crash is not a d260d7d backpatch gap; request for triage direction
Previous Message Keyerror Smart 2026-11-09 02:36:12 Re: BUG #19852: NOT IN -> anti-join conversion gives wrong results when the equality operator returns NULL for non-n