pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17176: Error raised on valid query
2+ messages / 2 participants
[nested] [flat]

* BUG #17176: Error raised on valid query
@ 2021-09-02 10:54  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2021-09-02 10:54 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: peter.davie@convergentsolutions.com.au

The following bug has been logged on the website:

Bug reference:      17176
Logged by:          Peter Davie
Email address:      peter.davie@convergentsolutions.com.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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #17176: Error raised on valid query
@ 2021-09-02 18:52  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2021-09-02 18:52 UTC (permalink / raw)
  To: peter.davie@convergentsolutions.com.au; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> 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'.

Doesn't matter.  Those expressions are not semantically equivalent,
and your assertion of that doesn't make it so.  The query has to be
valid for any values of the placeholders.

(If you'd like to substitute specific parameter values in advance of
semantic analysis, then do it on the client side.)

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-09-02 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 10:54 BUG #17176: Error raised on valid query PG Bug reporting form <noreply@postgresql.org>
2021-09-02 18:52 ` Tom Lane <tgl@sss.pgh.pa.us>

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