pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed(record = record) inconsistent with record_eq(arg1, arg2)
3+ messages / 3 participants
[nested] [flat]
* (record = record) inconsistent with record_eq(arg1, arg2)
@ 2023-07-31 13:45 jian he <jian.universality@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: jian he @ 2023-07-31 13:45 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
hi.
pg15: https://dbfiddle.uk/3_GxPdj4
not sure if it's a bug or I misunderstood.
select row(1,null::int) = (1,1::int); -- return null
select record_eq(row(1,null::int),(1,1::int)); --return false.
^ permalink raw reply [nested|flat] 3+ messages in thread
* (record = record) inconsistent with record_eq(arg1, arg2)
@ 2023-07-31 14:52 David G. Johnston <david.g.johnston@gmail.com>
parent: jian he <jian.universality@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: David G. Johnston @ 2023-07-31 14:52 UTC (permalink / raw)
To: jian he <jian.universality@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Monday, July 31, 2023, jian he <jian.universality@gmail.com> wrote:
>
> hi.
> pg15: https://dbfiddle.uk/3_GxPdj4
> not sure if it's a bug or I misunderstood.
>
> 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.
The SQL standard mandates the query behavior of the equals operator while
internal indexing and hash details require that the equality function not
return null.
Calling record_eq directly in SQL is unsupported so the claim that the
second query is buggy is incorrect altogether. We don’t promise any
particular result to the user in that situation, and could indeed remove
the function and the query could produce an error and we’d be technically
bug-free.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: (record = record) inconsistent with record_eq(arg1, arg2)
@ 2023-07-31 20:07 Tom Lane <tgl@sss.pgh.pa.us>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2023-07-31 20:07 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: jian he <jian.universality@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
"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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-07-31 20:07 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 13:45 (record = record) inconsistent with record_eq(arg1, arg2) jian he <jian.universality@gmail.com>
2023-07-31 14:52 ` David G. Johnston <david.g.johnston@gmail.com>
2023-07-31 20:07 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox