From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Vik Fearing <vik@postgresfriends.org>
To: Dennis Brouwer <dennis.brouwer@kizitos.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: John Naylor <john.naylor@enterprisedb.com>
Cc: David Micallef <david.j.micallef@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: group by true now errors with non-integer constant in GROUP BY
Date: Fri, 20 Oct 2023 08:32:57 +0200
Message-ID: <10a3ef130cd6d757690be076a6f47fe9351026d2.camel@cybertec.at> (raw)
In-Reply-To: <18ba0d29-0637-48c5-a11d-19f8672a8b0f@postgresfriends.org>
References: <CAJBCwCS7OuEUmGkrnu5Q8SmBP10njnEiX7vJiaxJURZXcCORyw@mail.gmail.com>
<CAFBsxsE_zy1Y=u2ZM6xZHFY2Cwfr_Uii=-irsHtCxrh6GnfBNA@mail.gmail.com>
<837886.1693252560@sss.pgh.pa.us>
<CAF31W9qz7qXxp=LADZv3+Y1CtJio5cvbU2FcbRyB9nW+R45xQg@mail.gmail.com>
<3af446dd6fbfdb6e08de95fc24e06081f78a6f15.camel@cybertec.at>
<18ba0d29-0637-48c5-a11d-19f8672a8b0f@postgresfriends.org>
On Fri, 2023-10-20 at 07:44 +0200, Vik Fearing wrote:
> > But according to my reading of the SQL standard, it only allows for
> > regular column references in GROUP BY. Unless I got something wrong,
> > that would mean the the ball is in Hibernate's court. It ought to
> > produce correct SQL.
>
> The answer is not as easy as that. It is true that the standard
> requires a <column reference> for each element of the GROUP BY clause,
> but it is also true that PostgreSQL allows arbitrary expressions.
>
> Why is this non-standard query allowed:
>
> vik=# select true group by true or true;
> ?column?
> ----------
> t
> (1 row)
>
>
> but not this one?
>
> vik=# select true group by true;
> ERROR: non-integer constant in GROUP BY
> LINE 1: select true group by true;
> ^
>
> I may have oversimplified this example, but as long as the value is
> present in the SELECT, logic would dictate that we can group by it.
I agree that it is desirable to fix this regression.
Still, we shouldn't exonerate Hibernate from fixing the junk SQL
it produces.
Yours,
Laurenz Albe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: laurenz.albe@cybertec.at, vik@postgresfriends.org, dennis.brouwer@kizitos.com, tgl@sss.pgh.pa.us, john.naylor@enterprisedb.com, david.j.micallef@gmail.com, peter.eisentraut@enterprisedb.com
Subject: Re: group by true now errors with non-integer constant in GROUP BY
In-Reply-To: <10a3ef130cd6d757690be076a6f47fe9351026d2.camel@cybertec.at>
References: <CAJBCwCS7OuEUmGkrnu5Q8SmBP10njnEiX7vJiaxJURZXcCORyw@mail.gmail.com> <CAFBsxsE_zy1Y=u2ZM6xZHFY2Cwfr_Uii=-irsHtCxrh6GnfBNA@mail.gmail.com> <837886.1693252560@sss.pgh.pa.us> <CAF31W9qz7qXxp=LADZv3+Y1CtJio5cvbU2FcbRyB9nW+R45xQg@mail.gmail.com> <3af446dd6fbfdb6e08de95fc24e06081f78a6f15.camel@cybertec.at> <18ba0d29-0637-48c5-a11d-19f8672a8b0f@postgresfriends.org> <10a3ef130cd6d757690be076a6f47fe9351026d2.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox