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 1qQZAe-000JBE-Hx for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Jul 2023 20:07:13 +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 1qQZAc-001h5O-Hg for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Jul 2023 20:07:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qQZAc-001h5E-9N for pgsql-bugs@lists.postgresql.org; Mon, 31 Jul 2023 20:07:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qQZAa-0003cl-HT for pgsql-bugs@lists.postgresql.org; Mon, 31 Jul 2023 20:07:11 +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 36VK74YM2947562; Mon, 31 Jul 2023 16:07:04 -0400 From: Tom Lane To: "David G. Johnston" cc: jian he , "pgsql-bugs@lists.postgresql.org" Subject: Re: (record = record) inconsistent with record_eq(arg1, arg2) In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Mon, 31 Jul 2023 07:52:09 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2947560.1690834024.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 31 Jul 2023 16:07:04 -0400 Message-ID: <2947561.1690834024@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Monday, July 31, 2023, jian he wrote: >> select row(1,null::int) =3D (1,1::int); -- return null >> select record_eq(row(1,null::int),(1,1::int)); --return false. > This isn=E2=80=99t a bug though I can=E2=80=99t point to the exact code = where the > difference manifests. Yeah, the difference in behavior is deliberate. See https://www.postgresql.org/docs/current/functions-comparisons.html#ROW-WIS= E-COMPARISON which documents the behavior of ROW(...) =3D ROW(...), and https://www.postgresql.org/docs/current/functions-comparisons.html#COMPOSI= TE-TYPE-COMPARISON which documents the behavior of record comparisons that are written in other ways, and explains the reason for the difference. The SQL standard governs the behavior of "ROW(...) =3D ROW(...)", but last I looked they don't really have a notion of composite-valued scalars, so the spec has nothing to say about what "row-valued-expression =3D row-valued-expression" should do. Even if it did, we would not change this, because it's too important to have a total ordering for composite columns. regards, tom lane