Remove support in ri_triggers.c for zero-column foreign keys?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Remove support in ri_triggers.c for zero-column foreign keys?
Дата
Msg-id 5764.1340226944@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Remove support in ri_triggers.c for zero-column foreign keys?  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
There is a nontrivial amount of code in ri_triggers.c that is concerned
with supporting foreign key constraints having zero columns.  There is
of course no support for this concept in the standard; the semantics
given to the case in the code are made up out of whole cloth.
(Basically, it says that such a constraint is satisfied if there's at
least one row in the PK table; contents don't matter.)  It is also not
possible to create such a constraint in Postgres, of course, which means
that the code in question is utterly untested.  I have no faith that all
the corner cases (most of which are just "do nothing if zero keys") are
correct even granting that the proposed semantics are reasonable.  In
particular, the corner case in ri_restrict_del that makes it do nothing
is certainly wrong, since it would need to disallow deleting the last
row in the PK table unless the FK table is empty.  I don't see exactly
how SET NULL or SET DEFAULT cases ought to behave either, except that
do-nothing is probably not it.

I think we should rip all that code out and instead put one test into
ri_FetchConstraintInfo insisting that the number of keys be > 0.
Alternatively, if we think this is actually a useful corner case,
somebody needs to put significant work into making the feature
accessible and then fixing it to work correctly.

Thoughts?
        regards, tom lane


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

Предыдущее
От: Cédric Villemain
Дата:
Сообщение: Re: pg_prewarm
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Remove support in ri_triggers.c for zero-column foreign keys?