Re: [PATCH] Add support for ON UPDATE/DELETE actions on ALTER CONSTRAINT

Поиск
Список
Период
Сортировка
От Fabrízio de Royes Mello
Тема Re: [PATCH] Add support for ON UPDATE/DELETE actions on ALTER CONSTRAINT
Дата
Msg-id CAFcNs+oCr6AgamXn6eaEhhhmysdmRbXXdy9gb6x7CouRxpiRYA@mail.gmail.com
обсуждение исходный текст
Ответ на [PATCH] Add support for ON UPDATE/DELETE actions on ALTER CONSTRAINT  (Matheus de Oliveira <matioli.matheus@gmail.com>)
Ответы Re: [PATCH] Add support for ON UPDATE/DELETE actions on ALTER CONSTRAINT
Список pgsql-hackers


On Tue, Feb 20, 2018 at 12:10 PM, Matheus de Oliveira <matioli.matheus@gmail.com> wrote:
>
> Hi all.
>
> I attached a patch to add support for changing ON UPDATE/DELETE actions of a constraint using ALTER TABLE ... ALTER CONSTRAINT.
>
> Besides that, there is a another change in this patch on current ALTER CONSTRAINT about deferrability options. Previously, if the user did ALTER CONSTRAINT without specifying an option on deferrable or initdeferred, it was implied the default options, so this:
>
>     ALTER TABLE tbl
>     ALTER CONSTRAINT con_name;
>
> Was equivalent to:
>
>     ALTER TABLE tbl
>     ALTER CONSTRAINT con_name NOT DEFERRABLE INITIALLY IMMEDIATE;
>
> If I kept it that way, it means that changing only ON UPDATE or ON DELETE would cause deferrability options to be changed to the default. Now, I keep an information of which options has actually been changed, so only the actual changes are persisted.
>
> But there are two exceptions (which I think that make sense):
> 1. If the user does only `ALTER CONSTRAINT ... INITIALLY DEFERRED`, no matter the previous value of deferrable, it will be set to true.
> 2. If the user does only `ALTER CONSTRAINT ... NOT DEFERRABLE`, no matter the previous value of initdeferred, it will be set to false.
>
> I have pondered to raise an exception in the above cases instead of forcing deferrable/initdeferred to valid values, but since the same behavior happens on ADD CONSTRAINT, I think this way is simpler.
>
> Since I'm a newbie on PG source code, this patch seems to be a bit big for me. So please, let me know what you think about it. Specially the change on Constraint struct on parsenode.h (and support to it on copyfuncs.c and outfuncs.c), I'm not 100% sure that is the best way to track if deferrability options were changed.
>
> Thanks a lot.
>

Great! 

I didn't read your patch yet but make sure to register it to the next open commitfest.

Regards,


--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgsql: Allow UNIQUE indexes on partitioned tables
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: [bug fix] Produce a crash dump before main() on Windows