Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types - Mailing list pgsql-bugs

From Richard Guo
Subject Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types
Date
Msg-id CAMbWs4_FLicDsNpotM0uEFkeveJ+gULe4VP0PyJ=FVsD9iYCGA@mail.gmail.com
Whole thread Raw
In response to Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_get_viewdef() produces non-round-trippable SQL for views with USING join on mismatched integer types
List pgsql-bugs
On Fri, Feb 27, 2026 at 3:27 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> The problem is obvious after looking at parseCheckAggregates: the
> RTE_GROUP RTE is manufactured using the groupClauses list after we
> have flattened that, which we are only doing for comparison purposes;
> it shouldn't affect what goes into the parse tree.  I experimented
> with just changing the order of operations, and that seems to fix it.

Right.  We should keep the unmodified GROUP BY expressions in the
parse tree, and then rely on the planner to flatten the join alias
vars within them.

+1 to the fix.

> The lack of any effect on check-world shows we need more test cases
> here ...

How about this new test case in the attached (parse_agg.c untouched)?

- Richard

Attachment

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #19417: '\dD' fails to list user-defined domains that shadow built-in type names (e.g., 'numeric')
Next
From: yafei wu
Date:
Subject: Re: BUG #19419: Cannot create custom functions using python3u