Re: Coercing compound types to use generic ROW comparison operators

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Randall Lucas <rlucas(at)tercent(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Coercing compound types to use generic ROW comparison operators
Date: 2007-10-11 18:52:08
Message-ID: 4155.1192128728@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Randall Lucas <rlucas(at)tercent(dot)com> writes:
> Is there a way I can convince my custom composite data type (point_pk)
> to use the row-wise comparison functions, so that I don't have to
> hackishly rewrite the comparison algorithm for each composite type?

Well, you can do this ...

regression=# create type point_pk as (x int, y int);
CREATE TYPE
regression=# create table foo(f1 point_pk, f2 point_pk);
CREATE TABLE
regression=# select * from foo where f1 = f2;
ERROR: operator does not exist: point_pk = point_pk
LINE 1: select * from foo where f1 = f2;
^
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.

regression=# select * from foo where row((f1).*) = row((f2).*);
f1 | f2
----+----
(0 rows)

> Using 8.1.5.

... but I think it only works as of 8.2.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dot Yet 2007-10-11 19:30:20 Postgres 8.2.5 compilation problem on OpenSolaris/Solaris
Previous Message Robert Treat 2007-10-11 18:16:04 Re: Support for distributed transactions in 8.2.5