pgsql: Allow specifying column list for foreign key ON DELETE SET actio
От | Peter Eisentraut |
---|---|
Тема | pgsql: Allow specifying column list for foreign key ON DELETE SET actio |
Дата | |
Msg-id | E1muuB2-0004XM-QE@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Allow specifying column list for foreign key ON DELETE SET actions Extend the foreign key ON DELETE actions SET NULL and SET DEFAULT by allowing the specification of a column list, like CREATE TABLE posts ( ... FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL (author_id) ); If a column list is specified, only those columns are set to null/default, instead of all the columns in the foreign-key constraint. This is useful for multitenant or sharded schemas, where the tenant or shard ID is included in the primary key of all tables but shouldn't be set to null. Author: Paul Martinez <paulmtz@google.com> Discussion: https://www.postgresql.org/message-id/flat/CACqFVBZQyMYJV=njbSMxf+rbDHpx=W=B7AEaMKn8dWn9OZJY7w@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/d6f96ed94e73052f99a2e545ed17a8b2fdc1fb8a Modified Files -------------- doc/src/sgml/catalogs.sgml | 12 +++ doc/src/sgml/ddl.sgml | 33 +++++++- doc/src/sgml/ref/alter_table.sgml | 2 +- doc/src/sgml/ref/create_table.sgml | 24 ++++-- src/backend/catalog/heap.c | 2 + src/backend/catalog/index.c | 2 + src/backend/catalog/pg_constraint.c | 53 +++++++++++- src/backend/commands/tablecmds.c | 97 +++++++++++++++++++-- src/backend/commands/trigger.c | 2 + src/backend/commands/typecmds.c | 2 + src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/gram.y | 134 +++++++++++++++++++++++++----- src/backend/utils/adt/ri_triggers.c | 115 ++++++++++++++++++------- src/backend/utils/adt/ruleutils.c | 10 +++ src/backend/utils/cache/relcache.c | 2 +- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_constraint.h | 11 ++- src/include/nodes/parsenodes.h | 1 + src/test/regress/expected/foreign_key.out | 71 ++++++++++++++++ src/test/regress/sql/foreign_key.sql | 51 ++++++++++++ 22 files changed, 557 insertions(+), 72 deletions(-)
В списке pgsql-committers по дате отправления: