Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, 'pinker *EXTERN*' <pinker(at)onet(dot)eu>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?
Date: 2015-09-17 14:47:52
Message-ID: 55FAD298.4090607@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/17/2015 07:34 AM, Tom Lane wrote:
> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
>> On 09/17/2015 06:54 AM, Tom Lane wrote:
>>> Well, that's true: the parser actually looks up the operator named "<>"
>>> for the given data types, and IS DISTINCT FROM is just a prefilter on
>>> that to do the right thing with nulls. So because type point has an
>>> operator that's physically named "<>", that case works.
>
>> If you use '<>' explicitly, otherwise:
>> test=> select '(1,2)'::point is distinct from '(1,3)'::point;
>> ERROR: operator does not exist: point = point
>
> Ah, sorry, actually what IS [NOT] DISTINCT FROM looks up is the "="
> operator.

So the docs should be changed?

As they stand now:

http://www.postgresql.org/docs/9.4/interactive/functions-comparison.html

"For non-null inputs, IS DISTINCT FROM is the same as the <> operator. "

That did not indicate to me the '=' was important to IS DISTINCT ON.
Then again I may need more attention from the clue stick:)

The core point remains, though, that this is a name-based
> lookup rather than an opclass-based one. I'd like to get us moved
> over to using opclass-based lookups for all cases where the system
> currently assumes that operators named "=" or "<>" necessarily behave
> in a particular way. However, that would leave point and some of the
> other weirder datatypes even further out in the cold than they are now.
>
> regards, tom lane
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-09-17 14:51:57 Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?
Previous Message Tom Lane 2015-09-17 14:34:06 Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?