Re: [PATCH] Support for foreign keys with arrays

From: Noah Misch <noah(at)leadboat(dot)com>
To: Gabriele Bartolini <gabriele(dot)bartolini(at)2ndQuadrant(dot)it>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>
Subject: Re: [PATCH] Support for foreign keys with arrays
Date: 2011-12-12 00:45:06
Message-ID: 20111212004506.GB10399@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 10, 2011 at 09:47:53AM +0100, Gabriele Bartolini wrote:
> Il 20/11/11 14:05, Noah Misch ha scritto:
>> What about making ON UPDATE CASCADE an error? That way, we can say that ARRAY
>> <action> always applies to array elements, and plain<action> always applies to
>> entire rows.
>>
>> SET DEFAULT should now be fine to allow. It's ARRAY SET DEFAULT, in your new
>> terminology, that wouldn't make sense.
>
> I have tried to gather your ideas with Gianni's and come to a
> compromise, which I hope you can both agree on.
>
> The reason why I would be inclined to leave CASCADE act on rows (rather
> than array elements as Gianni suggests) is for backward compatibility
> (people that are already using referential integrity based on array
> values). For the same reason, I am not sure whether we should raise an
> error on update, but will leave this for later.

Your conclusion is reasonable, but I don't understand this argument for it. The
patch does not change the meaning of any SQL that works today.

> So, here is a summary:
>
> --------------- --------- ---------
> | ON | ON |
> Action | DELETE | UPDATE |
> --------------- --------- ---------
> CASCADE | Row | Error |
> SET NULL | Row | Row |
> SET DEFAULT | Row | Row |
> ARRAY CASCADE | Element | Element |
> ARRAY SET NULL | Element | Element |
> NO ACTION | - | - |
> RESTRICT | - | - |
> --------------- --------- ---------
>
> If that's fine with you guys, Marco and I will refactor the development
> based on these assumptions.

Looks fine.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2011-12-12 00:46:17 Re: [PATCH] Support for foreign keys with arrays
Previous Message Andres Freund 2011-12-11 22:46:07 Re: Command Triggers