Re: Comparing arrays of composite types - Mailing list pgsql-general

From Tom Lane
Subject Re: Comparing arrays of composite types
Date
Msg-id 9512.1250885560@sss.pgh.pa.us
Whole thread Raw
In response to Comparing arrays of composite types  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Responses Re: Comparing arrays of composite types  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
List pgsql-general
Alban Hertroys <dalroi@solfertje.student.utwente.nl> writes:
> I defined a type:
> CREATE TYPE unit_token AS (
>     base_unit    TEXT,
>     unit_base    INT
> );

> If I try to join on tokens or try to create an index over that column
> I get: "ERROR:  could not identify a comparison function for type
> unit_token".

As noted, there is a built-in solution as of 8.4.

> I have created operators on unit_token for =, <, <=, > and >=, but
> either I did something wrong defining my operators or the error is
> pointing to some other problem.

The mere fact that the operator is named '=' means nothing to Postgres.
You need to create an operator class or family that shows the operator
is equality in a btree opclass.  Array comparison looks for the default
btree opclass for the element data type to decide what to do.

            regards, tom lane

pgsql-general by date:

Previous
From: David Kerr
Date:
Subject: Re: Schema diff tool?
Next
From: Nathan Jahnke
Date:
Subject: bytea corruption?