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

Поиск
Список
Период
Сортировка
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.

Regards,
--
Matheus de Oliveira


Вложения

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

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: NEXT VALUE FOR sequence
Следующее
От: Aleksander Alekseev
Дата:
Сообщение: Re: [PATCH] Add a few suppression rules for Valgrind