Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type?
От | David G. Johnston |
---|---|
Тема | Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type? |
Дата | |
Msg-id | CAKFQuwYGAUzF7T=ENnn2oPNTRaZxkQvyPDvVVWtBiba84zxDqw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Shouldn't "WHEN (OLD.* IS DISTINCT FROM NEW.*)" clause be independent from data type? (Adrian Klaver <adrian.klaver@aklaver.com>) |
Список | pgsql-general |
On 09/17/2015 06:32 AM, Albe Laurenz wrote:pinker wrote:I've tried to write audit trigger which fires only when data changed, so I used "WHEN (OLD.* IS
DISTINCT FROM NEW.*)" clause as described in documentation
<http://www.postgresql.org/docs/9.4/static/sql-createtrigger.html> . Should this clause be independent
from data type? because an error occurs when I'm trying to modify row with point data type: ERROR:
could not identify an equality operator for type point
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.
So:
test=> select '(1,2)'::point <> '(1,2)'::point;
?column?
----------
f
(1 row)
test=> select '(1,2)'::point <> '(1,3)'::point;
?column?
----------
t
test=> select '(1,2)'::point <> null;
?column?
----------
(1 row)
SELECT not ('(0,4)'::point = '(1,2)'::point)
ERROR: operator does not exist: point = point
If it calling it a bug gets it changed I'm game...but IS DISTINCT FROM apparently looks for an equality operator and then performs negation instead of looking for a "non-equality" operator. Since the latter doesn't really even make sense (TBH it's probably syntatic sugar transformed by the parser) I don't blame it.
David J.
В списке pgsql-general по дате отправления: