Re: GROUP BY DISTINCT

Vik Fearing <vik@postgresfriends.org>

From: Vik Fearing <vik@postgresfriends.org>
To: Georgios Kokolatos <gkokolatos@protonmail.com>, pgsql-hackers@lists.postgresql.org
Cc: Erik Rijkers <er@xs4all.nl>
Date: 2021-03-02T16:51:52Z
Lists: pgsql-hackers, pgsql-docs

Attachments

On 3/2/21 4:06 PM, Georgios Kokolatos wrote:
> As a minor gripe, I would note the addition of list_int_cmp.
> The block
> 
> +               /* Sort each groupset individually */
> +               foreach(cell, result)
> +                       list_sort(lfirst(cell), list_int_cmp);
> 
> Can follow suit from the rest of the code, and define a static cmp_list_int_asc(), as
> indeed the same patch does for cmp_list_len_contents_asc.
> This is indeed point of which I will not hold a too strong opinion.

I did it this way because list_int_cmp is a general purpose function for
int lists that can be reused elsewhere in the future.  Whereas
cmp_list_len_contents_asc is very specific to this case so I kept it local.

I'm happy to change it around if that's what consensus wants.

> Overall :+1: from me.

Thanks for looking at it!

> I will be bumping to 'Ready for Committer' unless objections.

In that case, here is another patch that fixes a typo in the docs
mentioned privately to me by Erik.  The typo (and a gratuitous rebase)
is the only change to what you just reviewed.
-- 
Vik Fearing

Commits

  1. Use lfirst_int in cmp_list_len_contents_asc

  2. Fix misuse of foreach_delete_current().

  3. Implement GROUP BY DISTINCT