Re: Wrong results with grouping sets

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Sutou Kouhei <kou(at)clear-code(dot)com>
Cc: ashutosh(dot)bapat(dot)oss(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Wrong results with grouping sets
Date: 2024-07-16 07:57:52
Message-ID: CAMbWs4-E88w-=4kHXOBPfuisU14d+asOLO_A8JqqtHbkfJLyuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 15, 2024 at 4:38 PM Sutou Kouhei <kou(at)clear-code(dot)com> wrote:
> I'm not familiar with related codes but here are my
> comments:

Thanks for reviewing this patchset!

> + * Fields valid for a GROUP RTE (else NULL/zero):
>
> There is only one field and it's LIST. So how about using
> the following?
>
> * A field valid for a GROUP RTE (else NIL):

Good point. I ended up with

* Fields valid for a GROUP RTE (else NIL):

... since this is the pattern used by other types of RTEs that have
only one field.

> If we want to reuse flatten_join_alias_vars_context for
> flatten_group_exprs(), how about renaming it?
> flatten_join_alias_vars() only uses
> flatten_join_alias_vars_context for now. So the name of
> flatten_join_alias_vars_context is meaningful. But if we
> want to flatten_join_alias_vars_context for
> flatten_group_exprs() too. The name of
> flatten_join_alias_vars_context is strange.

I think the current name should be fine. It's not uncommon that we
reuse the same structure intended for other functions within one
function.

> Can the "te->resname == NULL" case be happen? If so, how
> about adding a new test for the case?

It's quite common for te->resname to be NULL, such as when TargetEntry
is resjunk. I don't think a new case for this is needed. It should
already be covered in lots of instances in the current regression
tests.

> (BTW, is "unamed_col" intentional name? Is it a typo of
> "unnamed_col"?)

Yeah, it's a typo. I changed it to be "?column?", which is the
default name if FigureColname can't guess anything.

Here is an updated version of this patchset. I'm seeking the
possibility to push this patchset sometime this month. Please let me
know if anyone thinks this is unreasonable.

Thanks
Richard

Attachment Content-Type Size
v11-0001-Introduce-an-RTE-for-the-grouping-step.patch application/octet-stream 55.5 KB
v11-0002-Mark-expressions-nullable-by-grouping-sets.patch application/octet-stream 26.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Tachoires 2024-07-16 08:08:30 Re: Compress ReorderBuffer spill files using LZ4
Previous Message Anthonin Bonnefoy 2024-07-16 07:56:31 Re: Possible incorrect row estimation for Gather paths