Re: Issue with query_is_distinct_for() and grouping sets

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Issue with query_is_distinct_for() and grouping sets
Date: 2025-10-23 02:59:44
Message-ID: CAApHDvoDeKPZEUXzie71wGupUtcEdfXHjFNweWxgQ+DvYgsEAg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 23 Oct 2025 at 15:45, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
> On Wed, Oct 22, 2025 at 6:25 PM Richard Guo <guofenglinux(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-10-23 03:07:00 Re: Issue with query_is_distinct_for() and grouping sets
Previous Message Richard Guo 2025-10-23 02:44:54 Re: Issue with query_is_distinct_for() and grouping sets