Re: Arrays and foreign keys - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: Arrays and foreign keys
Date
Msg-id Pine.BSF.4.10.10008091047260.59889-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Arrays and foreign keys  (Kaare Rasmussen <kar@webline.dk>)
Responses Re: Arrays and foreign keys
List 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



pgsql-hackers by date:

Previous
From: Kaare Rasmussen
Date:
Subject: Arrays and foreign keys
Next
From: "Timothy H. Keitt"
Date:
Subject: Re: Arrays and foreign keys