BUG #17176: Error raised on valid query

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: peter(dot)davie(at)convergentsolutions(dot)com(dot)au
Subject: BUG #17176: Error raised on valid query
Date: 2021-09-02 10:54:03
Message-ID: 17176-4a88906336898128@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17176
Logged by: Peter Davie
Email address: peter(dot)davie(at)convergentsolutions(dot)com(dot)au
PostgreSQL version: 13.4
Operating system: Windows 10 64-bit
Description:

Hibernate is generating the following query:
select distinct date_part('year', internalme0_.when_occurred) as col_0_0_,
date_part('month', internalme0_.when_occurred) as col_1_0_, date_part('day',
internalme0_.when_occurred) as col_2_0_, date_part('hour',
internalme0_.when_occurred) as col_3_0_, date_part('minute',
internalme0_.when_occurred) as col_4_0_
from InternalMessages internalme0_
group by date_part('year', internalme0_.when_occurred) , date_part('month',
internalme0_.when_occurred) , date_part('day', internalme0_.when_occurred) ,
date_part('hour', internalme0_.when_occurred) , date_part('minute',
internalme0_.when_occurred) , internalme0_.when_occurred
order by date_part($1, internalme0_.when_occurred) asc, date_part($2,
internalme0_.when_occurred) asc, date_part($3, internalme0_.when_occurred)
asc, date_part($4, internalme0_.when_occurred) asc, date_part($5,
internalme0_.when_occurred) asc

The placeholders contain the values 'year', 'month', 'day', 'hour' and
'minute'.

The following error is generated when the query is executed:
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
at character 635

The Order By and Group By clauses are semantically equivalent.

I am in the process of raising a bug with the Hibernate team to correct the
generation of the query, however this query should be accepted.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-09-02 18:52:55 Re: BUG #17176: Error raised on valid query
Previous Message Peter Eisentraut 2021-09-02 08:15:37 Re: BUG #17158: Distinct ROW fails with Postgres 14