Re: Issue with query_is_distinct_for() and grouping sets - Mailing list pgsql-hackers

From David Rowley
Subject Re: Issue with query_is_distinct_for() and grouping sets
Date
Msg-id CAApHDvoDeKPZEUXzie71wGupUtcEdfXHjFNweWxgQ+DvYgsEAg@mail.gmail.com
Whole thread Raw
In response to Re: Issue with query_is_distinct_for() and grouping sets  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Issue with query_is_distinct_for() and grouping sets
List pgsql-hackers
On Thu, 23 Oct 2025 at 15:45, Richard Guo <guofenglinux@gmail.com> wrote:
>
> On Wed, Oct 22, 2025 at 6:25 PM Richard Guo <guofenglinux@gmail.com> 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 branch.
>
> Here is an updated patch that includes a commit message and adds a new
> test case involving DISTINCT clause used with GROUP BY.

I've not reviewed the patch, so I'm assuming this is broken and your
fix is correct, but I did see your commit message says:

> 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 joins being marked as
"Inner Unique" when they shouldn't, which could result in incorrect
query results.

David



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Issue with query_is_distinct_for() and grouping sets
Next
From: David Rowley
Date:
Subject: Re: Issue with query_is_distinct_for() and grouping sets