Re: BUG #6401: IS DISTINCT FROM improperly compares geomoetric datatypes

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: kenaniah(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6401: IS DISTINCT FROM improperly compares geomoetric datatypes
Date: 2012-01-19 10:25:36
Message-ID: 4F17EFA0.6050903@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 18.01.2012 23:14, kenaniah(at)gmail(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 6401
> Logged by: Kenaniah Cerny
> Email address: kenaniah(at)gmail(dot)com
> PostgreSQL version: 9.1.2
> Operating system: Centos 6 x86_64
> Description:
>
> ----
> SELECT point(2, 3) IS DISTINCT FROM point(2, 3);
> ----
> ERROR: operator does not exist: point = point
> LINE 1: SELECT point(2, 3) IS DISTINCT FROM point(2, 3)
> ^
> HINT: No operator matches the given name and argument type(s). You might
> need to add explicit type casts.
> ----
>
> According to the docs
> (http://www.postgresql.org/docs/current/static/functions-geometry.html#FUNCTIONS-GEOMETRY)
> the "same as" operator is the ~= operator, not the = operator.

Yeah, unfortunately the code to transform IS DISTINCT FROM into the
corresponding operator doesn't know about that. In fact, you might
expect it to complain about missing "<>" operator, as "IS DISTINCT FROM"
is really more like inequality, but the planner in fact implements it
using the = operator, negating the result. That's because it's more
common for datatypes to have a = operator than <>. Curiously, that's not
the case with point datatype - it has a <> operator but not =.

Frankly that's such a rare corner case that I'm not very enthusiastic
about fixing it. One idea would be to look up the type's b-tree sort
operators, and pick the equality operator from there. But point datatype
doesn't have b-tree sort operators, either, so it wouldn't help in this
case.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2012-01-19 13:30:44 Re: BUG #6401: IS DISTINCT FROM improperly compares geomoetric datatypes
Previous Message Heikki Linnakangas 2012-01-19 08:54:42 Re: BUG #6399: knngist sometimes returns tuples in incorrect order