[PATCH] Allow star syntax in GROUP BY, as a shorthand for all table columns

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема [PATCH] Allow star syntax in GROUP BY, as a shorthand for all table columns
Дата
Msg-id BANLkTinKs1dAUnB0Ct=OM3ncj0+PjjOkTw@mail.gmail.com
обсуждение исходный текст
Ответы Re: [PATCH] Allow star syntax in GROUP BY, as a shorthand for all table columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

This patch enables the syntax "GROUP BY tablename.*" in cases where
earlier you'd get the error "field must appear in the GROUP BY clause
or be used in an aggregate function"

I've often needed to write queries like this:
  SELECT a.x, a.y, a.z, sum(b.w) FROM a JOIN b USING (a_id) GROUP BY
a.x, a.y, a.z;
Now this becomes:
  SELECT a.x, a.y, a.z, sum(b.w) FROM a JOIN b USING (a_id) GROUP BY a.*;

The patch is so trivial that I'm wondering why it hasn't been
implemented before. I couldn't think of any assumptions being broken
by using row comparison instead of comparing each field separately.
But maybe I'm missing something.

If this patch looks reasonable, I guess the obvious next step is to
expand the "a.*" reference to the table's primary key columns and fill
in context->func_grouped_rels

Regards,
Marti

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavan Deolasee
Дата:
Сообщение: Re: Autoanalyze and OldestXmin
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Autoanalyze and OldestXmin