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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?
Дата
Msg-id 5914.1442498075@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-general
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 09/17/2015 06:32 AM, Albe Laurenz wrote:
>> I guess it is dependent on data type as it requires an equality operator,
>> and type "point" doesn't have one.

> To echo the OP, why is that?
> http://www.postgresql.org/docs/9.4/interactive/functions-comparison.html
> For non-null inputs, IS DISTINCT FROM is the same as the <> operator.

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.

However, in the given case, what gets found for "<>" is record_ne().
The record comparison functions apply btree comparison functions for
the individual column datatypes in the record --- and point does not
have a btree opclass.

If memory serves, for equal/not-equal comparisons a hash opclass would
work too, but point does not have that either.

Since type record *does* have btree/hash opclasses, it is not negotiable
that the component column types obey btree or at least hash semantics.
The only way to fix this would be to provide such opclasses for point.
Btree has the probably-fatal obstacle that there's no plausible linear
sort order for 2-D points.  It would be possible to make hash work, if
it weren't that point_eq() is fuzzy equality not exact equality.

            regards, tom lane


В списке pgsql-general по дате отправления:

Предыдущее
От: Melvin Davidson
Дата:
Сообщение: Re: clone_schema function
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?