Re: Wrong results with subquery pullup and grouping sets

2025-03-13 Thread Richard Guo
On Wed, Mar 12, 2025 at 6:29 PM Dean Rasheed wrote: > On Wed, 12 Mar 2025 at 07:45, Richard Guo wrote: > > For backpatching, 0001 seems more like a cosmetic change, and I don't > > think it needs to be backpatched. 0002 is a bug fix, but I'm not > > confident enough to commit it to the back bran

Re: Wrong results with subquery pullup and grouping sets

2025-03-12 Thread Richard Guo
On Wed, Mar 12, 2025 at 1:32 AM Dean Rasheed wrote: > On Mon, 10 Mar 2025 at 13:05, Richard Guo wrote: > > Attached are the patches. > These 2 comment changes from 0002 could be made part of 0001: > > 1). In pull_up_simple_subquery(), removing the word "Again" from the > comment following the de

Re: Wrong results with subquery pullup and grouping sets

2025-03-12 Thread Dean Rasheed
On Wed, 12 Mar 2025 at 07:45, Richard Guo wrote: > > I refined the comment in v2 and ended up with: > > * This analysis could be tighter: in particular, a non-strict > * construct hidden within a lower-level PlaceHolderVar is not > * reason to add another PHV. But for now it doe

Re: Wrong results with subquery pullup and grouping sets

2025-03-11 Thread Dean Rasheed
On Mon, 10 Mar 2025 at 13:05, Richard Guo wrote: > > Attached are the patches. > This looks good to me. I did some more testing, and I wasn't able to break it. Some minor nitpicks: These 2 comment changes from 0002 could be made part of 0001: 1). In pull_up_simple_subquery(), removing the word

Re: Wrong results with subquery pullup and grouping sets

2025-03-10 Thread Richard Guo
On Wed, Mar 5, 2025 at 8:01 PM Dean Rasheed wrote: > Yes, that makes sense, and it seems like a fairly straightforward > simplification, given that perform_pullup_replace_vars() sets it back > to false shortly afterwards. > > The same thing happens in pull_up_constant_function(). Thanks for looki

Re: Wrong results with subquery pullup and grouping sets

2025-03-05 Thread Dean Rasheed
On Wed, 5 Mar 2025 at 09:09, Richard Guo wrote: > > I noticed the adjacent code that sets wrap_non_vars to true if we > are considering an appendrel child subquery, and I doubt this is > necessary. > > /* > * If we are dealing with an appendrel member then anything that's not a > * simple Var

Re: Wrong results with subquery pullup and grouping sets

2025-03-05 Thread Richard Guo
On Wed, Mar 5, 2025 at 11:02 AM Richard Guo wrote: > It seems to me that simple Var expressions in a subquery's target list > also need to retain their separate identity in order to match grouping > set columns after subquery pullup, not just non-var expressions. I noticed the adjacent code that

Re: Wrong results with subquery pullup and grouping sets

2025-03-04 Thread Richard Guo
On Wed, Mar 5, 2025 at 11:02 AM Richard Guo wrote: > create table t (a int); > insert into t values (1); > > # select a, b > from (select a, a as b from t) ss > group by grouping sets(a, b) > having b = 1; > a | b > ---+--- > 1 | > (1 row) > > Note that the having clause filters out the wr