Re: (record = record) inconsistent with record_eq(arg1, arg2) - Mailing list pgsql-bugs

From Tom Lane
Subject Re: (record = record) inconsistent with record_eq(arg1, arg2)
Date
Msg-id 2947561.1690834024@sss.pgh.pa.us
Whole thread Raw
In response to (record = record) inconsistent with record_eq(arg1, arg2)  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Monday, July 31, 2023, jian he <jian.universality@gmail.com> wrote:
>> select row(1,null::int) = (1,1::int); -- return null
>> select record_eq(row(1,null::int),(1,1::int)); --return false.

> This isn’t a bug though I can’t 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-WISE-COMPARISON

which documents the behavior of ROW(...) = ROW(...), and

https://www.postgresql.org/docs/current/functions-comparisons.html#COMPOSITE-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(...) = 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 =
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



pgsql-bugs by date:

Previous
From: Kong Man
Date:
Subject: Re: pg_restore 14 skips ACL COLUMN when --schema is used
Next
From: Kong Man
Date:
Subject: Re: pg_restore 14 skips ACL COLUMN when --schema is used