Re: Trigger violates foreign key constraint

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Trigger violates foreign key constraint
Дата
Msg-id
2899874.1712515943@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Re: Trigger violates foreign key constraint Tom Lane <tgl@sss.pgh.pa.us>
Re: Trigger violates foreign key constraint Noah Misch <noah@leadboat.com>
Re: Trigger violates foreign key constraint shihao zhong <zhong950419@gmail.com>
Re: Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Re: Trigger violates foreign key constraint "David G. Johnston" <david.g.johnston@gmail.com>
Re: Trigger violates foreign key constraint "David G. Johnston" <david.g.johnston@gmail.com>
Re: Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Re: Trigger violates foreign key constraint Aleksander Alekseev <aleksander@timescale.com>
Re: Trigger violates foreign key constraint Pavel Luzanov <p.luzanov@postgrespro.ru>
Re: Trigger violates foreign key constraint Pavel Luzanov <p.luzanov@postgrespro.ru>
Re: Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Re: Trigger violates foreign key constraint Tom Lane <tgl@sss.pgh.pa.us>
Re: Trigger violates foreign key constraint Aleksander Alekseev <aleksander@timescale.com>
Re: Trigger violates foreign key constraint Tom Lane <tgl@sss.pgh.pa.us>
Re: Trigger violates foreign key constraint Aleksander Alekseev <aleksander@timescale.com>
Re: Trigger violates foreign key constraint Tom Lane <tgl@sss.pgh.pa.us>
Re: Trigger violates foreign key constraint Pavel Luzanov <p.luzanov@postgrespro.ru>
Re: Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Re: Trigger violates foreign key constraint Laurenz Albe <laurenz.albe@cybertec.at>
Laurenz Albe  writes:
> Patch v3 is attached.

I agree with documenting this hazard, but I think it'd be better
to do so in the "Triggers" chapter.  There is no hazard unless
you are writing user-defined triggers, which is surely far fewer
people than use foreign keys.  So I suggest something like the
attached.

			regards, tom lane

diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index a5390ff644..99d8b75fc5 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -354,6 +354,20 @@
     to avoid infinite recursion in such scenarios.
    
 
+   
+    PostgreSQL implements foreign key
+    constraints via system-defined AFTER triggers.
+    If a foreign key constraint specifies referential actions (that is,
+    cascading updates or deletes), these triggers issue ordinary SQL
+    update or delete commands on the referencing table to perform the
+    actions.  In particular, any user-defined triggers on the referencing
+    table will be fired.  If such a trigger modifies or blocks the effect
+    of one of these commands, the end result could be to break referential
+    integrity.  It is the trigger programmer's responsibility to avoid
+    that.  (Similar problems can arise in any case where different
+    triggers are working at cross-purposes.)
+   
+
    
     
      trigger
В списке pgsql-hackers по дате отправления
От: Alvaro Herrera
Дата:
От: Alexander Lakhin
Дата:
FAQ