Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLrqN-0007aV-Ol for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Sep 2021 18:53:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mLrqM-0003cd-O1 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Sep 2021 18:53:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLrpk-0001M8-67 for pgsql-bugs@lists.postgresql.org; Thu, 02 Sep 2021 18:53:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLrpi-000399-2E for pgsql-bugs@lists.postgresql.org; Thu, 02 Sep 2021 18:53:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 182IqtPX2264178; Thu, 2 Sep 2021 14:52:56 -0400 From: Tom Lane To: peter.davie@convergentsolutions.com.au cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17176: Error raised on valid query In-reply-to: <17176-4a88906336898128@postgresql.org> References: <17176-4a88906336898128@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 02 Sep 2021 10:54:03 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2264176.1630608775.1@sss.pgh.pa.us> Date: Thu, 02 Sep 2021 14:52:55 -0400 Message-ID: <2264177.1630608775@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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