Re: Comparing arrays of composite types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Comparing arrays of composite types
Дата
Msg-id 9512.1250885560@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Comparing arrays of composite types  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Ответы Re: Comparing arrays of composite types
Список 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 по дате отправления:

Предыдущее
От: David Kerr
Дата:
Сообщение: Re: Schema diff tool?
Следующее
От: Nathan Jahnke
Дата:
Сообщение: bytea corruption?