"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