Re: Issue with query_is_distinct_for() and grouping sets

2025-10-23 Thread Richard Guo
On Thu, Oct 23, 2025 at 1:33 PM David Rowley wrote: > On Thu, 23 Oct 2025 at 16:43, Richard Guo wrote: > > How about using the following wording in the commit message? > > > > " > > The previous logic in query_is_distinct_for() was incomplete because > > the check was insufficiently thorough and

Re: Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread David Rowley
On Thu, 23 Oct 2025 at 16:43, Richard Guo wrote: > How about using the following wording in the commit message? > > " > The previous logic in query_is_distinct_for() was incomplete because > the check was insufficiently thorough and could return false when it > should have returned true. > " "it

Re: Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread Richard Guo
On Thu, Oct 23, 2025 at 12:07 PM David Rowley wrote: > Or if it's a case of it returning false when it could have returned > true, then maybe the commit message should make that clear. I'm unable > to tell from reading it. Something like; "The previous logic in > query_is_distinct_for() was incomp

Re: Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread David Rowley
On Thu, 23 Oct 2025 at 15:59, David Rowley wrote: > > No backpatch as this could result in plan changes. > > If this is broken then it'll need to be backpatched as if that > function returns true when it should return false, then you could have > LEFT JOINs being removed when they shouldn't or joi

Re: Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread David Rowley
On Thu, 23 Oct 2025 at 15:45, Richard Guo wrote: > > On Wed, Oct 22, 2025 at 6:25 PM Richard Guo wrote: > > Attached is a patch along the lines of option #2. The LCOV report > > indicates that there is currently no test coverage for the "else if > > (query->groupingSets)" branch in query_is_dist

Re: Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread Richard Guo
On Wed, Oct 22, 2025 at 6:25 PM Richard Guo wrote: > Attached is a patch along the lines of option #2. The LCOV report > indicates that there is currently no test coverage for the "else if > (query->groupingSets)" branch in query_is_distinct_for(). This patch > also adds test cases to cover that

Issue with query_is_distinct_for() and grouping sets

2025-10-22 Thread Richard Guo
While working on the fix for the push-down-HAVING optimization, I noticed $subject. query_is_distinct_for() is intended to determine whether a query never returns duplicates of the specified columns. For a query using grouping sets, if there are no grouping expressions, we know there are no non-e