pgsql: Refuse ATTACH of a table referenced by a foreign key
От | Alvaro Herrera |
---|---|
Тема | pgsql: Refuse ATTACH of a table referenced by a foreign key |
Дата | |
Msg-id | E1scCgY-003Kt4-OH@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Refuse ATTACH of a table referenced by a foreign key Trying to attach a table as a partition which is already on the referenced side of a foreign key on the partitioned table that it is being attached to, leads to strange behavior: we try to clone the foreign key from the parent to the partition, but this new FK points to the partition itself, and the mix of pg_constraint rows and triggers doesn't behave well. Rather than trying to untangle the mess (which might be possible given sufficient time), I opted to forbid the ATTACH. This doesn't seem a problematic restriction, given that we already fail to create the foreign key if you do it the other way around, that is, having the partition first and the FK second. Backpatch to all supported branches. Reported-by: Alexander Lakhin <exclusion@gmail.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Discussion: https://postgr.es/m/18541-628a61bc267cd2d3@postgresql.org Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ada34d7146c343a143de811eefc4fdd190ce40a5 Modified Files -------------- src/backend/commands/tablecmds.c | 17 +++++++++++++++++ src/test/regress/expected/foreign_key.out | 17 +++++++++++++++++ src/test/regress/sql/foreign_key.sql | 17 +++++++++++++++++ 3 files changed, 51 insertions(+)
В списке pgsql-committers по дате отправления: