Re: [PATCH] Support for foreign keys with arrays - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Support for foreign keys with arrays
Date
Msg-id 1652.1321506512@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Support for foreign keys with arrays  (Noah Misch <noah@leadboat.com>)
Responses Re: [PATCH] Support for foreign keys with arrays  (Josh Berkus <josh@agliodbs.com>)
Re: [PATCH] Support for foreign keys with arrays  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: [PATCH] Support for foreign keys with arrays  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> On Fri, Nov 04, 2011 at 01:48:02PM +0100, Gabriele Bartolini wrote:
>> CREATE TABLE pt (
>> id INTEGER PRIMARY KEY,
>> 
>> CREATE TABLE ft (
>> id SERIAL PRIMARY KEY,
>> pids INTEGER[] REFERENCES pt,

> I'm assuming the SQL spec says nothing about a feature like this?

I'm pretty certain that the SQL spec flat out forbids this.

The least we could do is invent some non-spec syntax that makes the
intention clear, rather than having the system assume that an error case
was intended to mean something else.  Maybe
pids INTEGER[] ARRAY REFERENCES pt,

or something like that.  (ARRAY is a fully reserved word already,
so I think this syntax should work, but I've not tried it.)

BTW, has anyone thought through whether this is a sane idea at all?
It seems to me to be full of cases that will require rather arbitrary
decisions, like whether ON DELETE CASCADE should involve deleting the
whole row or just one array element.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: ISN was: Core Extensions relocation
Next
From: Josh Berkus
Date:
Subject: Re: [PATCH] Support for foreign keys with arrays