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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Vik Fearing <vik(at)postgresfriends(dot)org>, Dennis Brouwer <dennis(dot)brouwer(at)kizitos(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, David Micallef <david(dot)j(dot)micallef(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: group by true now errors with non-integer constant in GROUP BY
Date: 2023-10-20 06:32:57
Message-ID: 10a3ef130cd6d757690be076a6f47fe9351026d2.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-10-20 08:00:00 BUG #18163: Catcache entry invalidation might be missed when toast processed inside CatalogCacheCreateEntry
Previous Message Vik Fearing 2023-10-20 06:20:27 Re: group by true now errors with non-integer constant in GROUP BY