Re: select distinct point?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select distinct point?
Date: 2003-01-04 01:54:39
Message-ID: 23964.1041645279@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greg Stark <gsstark(at)mit(dot)edu> writes:
> You can't select distinct on the point datatype column? I see why it's
> nonobvious how to sort points but then how come it works fine to select
> distinct on a box column?

Depends on your definition of "works fine", I suppose.

regression=# create table test2 (b box);
CREATE TABLE
regression=# insert into test2 values ('(1,1), (2,2)');
INSERT 680713 1
regression=# insert into test2 values ('(1,1), (1.5,3)');
INSERT 680714 1
regression=# select * from test2;
b
---------------
(2,2),(1,1)
(1.5,3),(1,1)
(2 rows)

regression=# select distinct * from test2;
b
-------------
(2,2),(1,1)
(1 row)

This is not DISTINCT's fault:

regression=# select '(2,2),(1,1)'::box = '(1.5,3),(1,1)'::box;
?column?
----------
t
(1 row)

Type box has '<' and '=' operators, but they're defined to compare the
areas of boxes. It bothers me that the name '=' was used for an
operator that is not box equality by any sane standard, but that's how
it's defined at the moment. Poor DISTINCT, of course, just applies the
operators that have the right names; it's got no way to know that the
semantics aren't sensible.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-01-04 03:15:08 Re: ident inconsistency
Previous Message Joe Conway 2003-01-04 01:41:56 Re: example table functions?