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

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Joel Rodrigues <borgempath(at)Phreaker(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: "...integer[] references..." = error
Date: 2002-09-05 17:31:15
Message-ID: 20020905102626.W69205-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2002-09-05 17:33:54 Re: "...integer[] references..." = error
Previous Message Amin Abdulghani 2002-09-05 17:29:30 Re: Transaction Id wraparounds