Re: "...integer[] references..." = error

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: "...integer[] references..." = error
Дата
Msg-id 20020905102626.W69205-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на "...integer[] references..." = error  (Joel Rodrigues <borgempath@Phreaker.net>)
Список pgsql-general
On Thu, 5 Sep 2002, Joel Rodrigues wrote:

> Hello,
>
> Does anyone know why trying to create this column:
>
> "role    INTEGER[] REFERENCES role (roleid)"
>
>
> returns this error:
>
>
> ERROR:  Unable to identify an operator '=' for types 'integer[]'
> and 'integer'
>          You will have to retype this query using an explicit cast
>
> psql:individual.sql:22: ERROR:  Unable to identify an
> operator '=' for types 'integer[]' and 'integer'
>          You will have to retype this query using an explicit cast

Because int[] and int are not comparable types (in this case meaning
that there is not an = operator between them) which is one of the
requirements (IIRC) for making a foreign key between two columns.

I could imagine that it might be reasonable to do all elements must
exist for array type -> base type, although I'd think it might get
wierd for multidimensional arrays, and without an intelligent index
on that column the reverse checks for update/delete on the pk table
would probably be rather painful.

In general the workaround is to normalize with a details table.


В списке pgsql-general по дате отправления:

Предыдущее
От: Amin Abdulghani
Дата:
Сообщение: Re: Transaction Id wraparounds
Следующее
От: "Nigel J. Andrews"
Дата:
Сообщение: Re: "...integer[] references..." = error