Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtj4H-00DfPo-TH for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Oct 2023 06:33:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qtj4F-00E2zw-Li for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Oct 2023 06:33:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtj4F-00E2zd-7H for pgsql-bugs@lists.postgresql.org; Fri, 20 Oct 2023 06:33:08 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qtj48-001NZn-DL for pgsql-bugs@lists.postgresql.org; Fri, 20 Oct 2023 06:33:06 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-53dd3f169d8so546775a12.3 for ; Thu, 19 Oct 2023 23:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1697783578; x=1698388378; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=ueAPkr2ZvWr47eEGp8yAW7mRJOs8dG7DZ6mpDDo5CFM=; b=lT/AzdbG2pFLlm/7+1kNC3p3ykciuPqHDC4EFLFrn4ivogelIr7JvR1bbxZcljJWc0 tGuiUcfzh8voHa4mTJj8F2H+eo1eRHbm37/sO5J1uxwcq0XgvBIaDKwRJNuJt6egZNlj H/J1Om79ZOUZjlgvTD5MmVq8erDK8v2ZoNN/PzHLJs5U2wFSJNu6CCC3is/vEkHQTUUu U4WKwDboBO84nc+j9XOGsNwzBc/cfKacXVv869BvjIpEDdwriEciqZg70Qohk1L4dxZW i80DZHms+bpl/snfueTUQ6hDnk7PkLujpnwwkYOamD/Zbpgxx1uSRhBHeC2JNUfaqCAJ qKUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697783578; x=1698388378; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ueAPkr2ZvWr47eEGp8yAW7mRJOs8dG7DZ6mpDDo5CFM=; b=aMZWv7oOsU3dUFhVmDanhWYVwAaRorU10OlhTUHsSfvol339LDfF2T0eaexp/EZV+T qS5muLjSRbusf0sLmz9lfiCKb7VfTYH5FgDpzO0228GeMCbdy9F5FngtyIHg6viMOrqu +yThVLJOhNR7HruNO4QL8yT7eb98YduvF9ytzSPyBJq9m0W2gte4lQUwE0wB9MYaozaY qZz7MHYMCoTJ7sYJDTiutuQEFupqNB7izaJpTHFT7vyXbse3pNR9EBKoEd5bcrYgIubW I+K+QfEXWQcWb/ZrCWn71FACDWxHJyMatAvtFAPBtUWE2mqyJ2XQYCQyMD6ykNGLUSHj LkcQ== X-Gm-Message-State: AOJu0Yw1s3KBFFdFDnQJ2hfYRsH+pZBAbeef8nPkWHMcgPJk4J19eez+ ut0c3+V1IqNbLs4AwbRfNmv4dA== X-Google-Smtp-Source: AGHT+IE0pE6mLjAlxFkqYjCGg82wXcg7RGcxdPLd8W3DizcyIWiPas+JZ2q2FX+IhRQtsKxdQgbq9A== X-Received: by 2002:a05:6402:34c7:b0:534:78a6:36c4 with SMTP id w7-20020a05640234c700b0053478a636c4mr736143edc.36.1697783578213; Thu, 19 Oct 2023 23:32:58 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:e9d0:9516:cd08:a776:435d]) by smtp.gmail.com with ESMTPSA id n15-20020aa7c68f000000b0053eb9af1e15sm828327edq.77.2023.10.19.23.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 23:32:57 -0700 (PDT) Message-ID: <10a3ef130cd6d757690be076a6f47fe9351026d2.camel@cybertec.at> Subject: Re: group by true now errors with non-integer constant in GROUP BY From: Laurenz Albe To: Vik Fearing , Dennis Brouwer , Tom Lane Cc: John Naylor , David Micallef , Peter Eisentraut , pgsql-bugs@lists.postgresql.org Date: Fri, 20 Oct 2023 08:32:57 +0200 In-Reply-To: <18ba0d29-0637-48c5-a11d-19f8672a8b0f@postgresfriends.org> References: <837886.1693252560@sss.pgh.pa.us> <3af446dd6fbfdb6e08de95fc24e06081f78a6f15.camel@cybertec.at> <18ba0d29-0637-48c5-a11d-19f8672a8b0f@postgresfriends.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.=C2=A0 Unless I got something wro= ng, > > that would mean the the ball is in Hibernate's court.=C2=A0 It ought to > > produce correct SQL. >=20 > The answer is not as easy as that.=C2=A0 It is true that the standard=20 > requires a for each element of the GROUP BY clause,= =20 > but it is also true that PostgreSQL allows arbitrary expressions. >=20 > Why is this non-standard query allowed: >=20 > vik=3D# select true group by true or true; > =C2=A0 ?column? > ---------- > =C2=A0 t > (1 row) >=20 >=20 > but not this one? >=20 > vik=3D# select true group by true; > ERROR:=C2=A0 non-integer constant in GROUP BY > LINE 1: select true group by true; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ >=20 > I may have oversimplified this example, but as long as the value is=20 > 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