Re: Arrays and foreign keys

Stephan Szabo <sszabo@megazone23.bigpanda.com>

From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Kaare Rasmussen <kar@webline.dk>
Cc: pgsql-hackers@postgresql.org
Date: 2000-08-09T17:52:17Z
Lists: pgsql-hackers
Well, the two types aren't the same (one is an integer the
other an integer array,) so I wouldn't expect it to work. Note: 
This shows another thing it probably should check before allowing 
the constraint to be created.

I don't know if these belong in TODO, but this might
be the appropriate entry.
* Make sure that types used in foreign key constraints
  are comparable.

Stephan Szabo
sszabo@bigpanda.com

On Tue, 8 Aug 2000, Kaare Rasmussen wrote:

> Seems that it's not possible to combine arrays and foreign keys ?
> 
> CREATE TABLE table1 (
>        fld1               integer NOT NULL,
>        number          integer,
>        level              integer,
>  PRIMARY KEY (fld1)
> );
> 
> CREATE TABLE table2 (
>       pkey             integer NOT NULL,
>       arvar              integer[],
>  PRIMARY KEY (pkey),
>  FOREIGN KEY (arvar) REFERENCES table1(fld1)
> );
> 
> 
> This works, but the following insert complains that 
> 
> ERROR:  Unable to identify an operator '=' for types 'int4' and '_int4'
>         You will have to retype this query using an explicit cast