Re: group by true now errors with non-integer constant in GROUP BY

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: group by true now errors with non-integer constant in GROUP BY
Дата
Msg-id 837886.1693252560@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: group by true now errors with non-integer constant in GROUP BY  (John Naylor <john.naylor@enterprisedb.com>)
Ответы Re: group by true now errors with non-integer constant in GROUP BY  (Andrew Dunstan <andrew@dunslane.net>)
Re: group by true now errors with non-integer constant in GROUP BY  (David Rowley <dgrowleyml@gmail.com>)
Re: group by true now errors with non-integer constant in GROUP BY  (Dennis Brouwer <dennis.brouwer@kizitos.com>)
Список pgsql-bugs
John Naylor <john.naylor@enterprisedb.com> writes:
> On Mon, Aug 28, 2023 at 1:28 PM David Micallef <david.j.micallef@gmail.com>
> wrote:
>> ERROR:  non-integer constant in GROUP BY

> I can confirm the reproducer script fails with commit 941460fcf731a ("Add
> Boolean node"). (So actually all 15.x were affected.)

Yeah, same result from bisecting here.  I had had the idea that this
was an intentional semantics change to reduce the probability of error,
but that commit didn't mention any such thing, so that's a tough claim
to make as far as the historical intent goes.

Having said that ... it seems to me that it was pure coincidence that
"group by true" worked before, and I'm not sure we should install a
grotty hack to make it work again.  In particular, why should we allow
Boolean Consts but not other non-integer Consts?  (And if we do, don't
we need to change that error message?)

The bigger picture here is: what is the use-case for grouping by a
constant at all?  Assuming that it is an error seems like a good
foolproofing restriction.  The reason we felt we could keep the
"group by N" SQL92-ism after SQL99 redefined GROUP BY arguments is
exactly that there's no obvious use-case for grouping by a constant.
As soon as you allow it, "group by N" becomes hopelessly ambiguous.

So my druthers would be to reject this as a non-bug.  But if we accept
it as something to fix, we need to revisit exactly which conditions
are errors here.  Perhaps rather than "reject all non-integer cases",
we should only reject the Float case, and let others fall through to
the SQL99 code.  (I would not be happy allowing Float, because that'd
mean that "group by 4" and "group by 4.0" mean fundamentally different
things.)

            regards, tom lane



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

Предыдущее
От: John Naylor
Дата:
Сообщение: Re: group by true now errors with non-integer constant in GROUP BY
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: group by true now errors with non-integer constant in GROUP BY