Re: BUG #19353: Error XX000 if referencing expanded array in grouping set: variable not found in subplan target list

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tender Wang <tndrwang@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, marian.muller@serli.com, pgsql-bugs@lists.postgresql.org
Date: 2025-12-25T03:58:47Z
Lists: pgsql-bugs
On Wed, Dec 24, 2025 at 11:40 AM Tender Wang <tndrwang@gmail.com> wrote:
> Richard Guo <guofenglinux@gmail.com> 于2025年12月24日周三 10:15写道:
>> The patch also introduces a new extern function that calls the
>> workhorse with the grouping flag enabled.  Additionally, it adds two
>> new fields to struct split_pathtarget_context, but that struct is
>> defined entirely within the .c file.

> It is safe if the struct is only used in a .c file. It would be better to add a note in the comment for the struct to notice.

Yeah, a struct defined in .c file should be safe to modify.  My main
concern was adding a new extern function to back-branches, as it can
break forward compatibility (like an extension built on 18.2 not
working on 18.1).

After a quick discussion on Discord, I believe it is safe to proceed.
Forward compatibility issues can only happen if a new extern function
is added to core and meanwhile called by an extension, which is quite
rare.

Thus, I have pushed and back-patched this fix.

Thank you, Marian, for the report.  It was a good find.  The fix will
be available in 18.2, which is scheduled for release in February.

- Richard