pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 孙冰 <subi.the.dream.walker@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Test of value equivalency of row type, feature or bug?
Date: Thu, 20 Dec 2018 09:35:00 -0500
Message-ID: <11491.1545316500@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+czfDUU+SU9P73y5mg7bvsp6EQyNKoMcdSP8tQoRbDU_UF8ww@mail.gmail.com>
References: <CA+czfDUU+SU9P73y5mg7bvsp6EQyNKoMcdSP8tQoRbDU_UF8ww@mail.gmail.com>

=?UTF-8?B?5a2Z5Yaw?= <subi.the.dream.walker@gmail.com> writes:
> select t=t from (select 1, null) t;

> If I manage to catch the documents, the result of the query should be null,
> as an equivalency comparison of null-contained row-typed values is null.
> Surprisingly, the query result turns out to be true.

> Is this behavior a feature or a bug?

It's a feature.  The btree comparison functions (<, =, >, etc) for
composite types have to provide a total order for their datatypes,
and treating an individual null field as a reason to return null
would break that.

The whole question of when a composite value "is null" is messy.
It ought not be --- IMO, either you have a tuple or you don't ---
but the SQL committee did nobody any favors with their creative
specification for what "x IS [NOT] NULL" means for composite x.

Having said that, though, perhaps "t IS NOT NULL" would do what
you want here, since it's defined to be true only when each of
t's fields is not null.

			regards, tom lane




view thread (4+ messages)  latest in thread

Message-ID: <11491.1545316500@sss.pgh.pa.us>
Permalink:  ../11491.1545316500@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11491.1545316500@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, subi.the.dream.walker@gmail.com
  Subject: Re: Test of value equivalency of row type, feature or bug?
  In-Reply-To: <11491.1545316500@sss.pgh.pa.us>
  References: <CA+czfDUU+SU9P73y5mg7bvsp6EQyNKoMcdSP8tQoRbDU_UF8ww@mail.gmail.com> <11491.1545316500@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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