Re: Creating a VIEW with a POINT column

From: Jan Urbański <j(dot)urbanski(at)students(dot)mimuw(dot)edu(dot)pl>
To: Nick <nboutelier(at)hotmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Creating a VIEW with a POINT column
Date: 2008-06-25 23:03:57
Message-ID: 4862CEDD.8020804@students.mimuw.edu.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Nick wrote:
> Nope, im not ordering by the POINT column. Heres an example...
>
> CREATE VIEW myview AS
> SELECT table1.title, table1.sorter, table1.xy FROM table1 UNION
> SELECT table2.title, table2.sorter, table2.xy FROM table2;

Hmm, the error seems to be coming from UNION. It's because Postgres
implements UNION by sorting both result sets merging them together.
Sample queries that also fail:

SELECT * FROM myview;
SELECT DISTINCT * FROM table1;
SELECT title, sorter, xy FROM table1 GROUP BY title, sorter, xy;

All three try to sort the table first, and as there's no comparision
operator for the POINT datatype, they fail. Which seems to be wrong - if
there is no comparision operator, you still can do DISTINCT, only less
efficiently.

The quick solution I'd propose is replacing UNION with UNION ALL. This
will not throw away duplicate entries present in both table1 and table2,
but if you can live with that, it will work. Remeber though, it changes
the semantic of that view, so think carefuly before doing that.

I guess some senior hacker should confirm, but I believe this is a bug.

Jan

--
Jan Urbanski
GPG key ID: E583D7D2

ouden estin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-06-25 23:18:06 Re: CVS Head psql bug?
Previous Message Tatsuo Ishii 2008-06-25 23:02:58 Re: CVS Head psql bug?