Re: Trigger violates foreign key constraint

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers(at)postgresql(dot)org
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Trigger violates foreign key constraint
Date: 2023-12-22 11:39:23
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2023-12-22 at 10:59 +0300, Pavel Luzanov wrote:
> Please, consider small suggestion to replace last sentence.
> - This is not considered a bug, and it is the responsibility of the user
> to write triggers so that such problems are avoided.
> + It is the trigger programmer's responsibility to avoid such scenarios.
> To be consistent with the sentence about recursive trigger calls: [1]
> "It is the trigger programmer's responsibility to avoid infinite
> recursion in such scenarios."

Yes, that is better - shorter and avoids passive mode. Changed.

> Also I don't really like "This is not considered a bug" part, since it
> looks like an excuse.

In a way, it is an excuse, so why not be honest about it.

The example you provided in your other message (cascading triggers
fail if the table ovner has revoked the required permissions from
herself) is not really about breaking foreign keys. You hit a
surprising error, but referential integrity will be maintained.

Patch v3 is attached.

Laurenz Albe

Attachment Content-Type Size
v3-0001-Document-foreign-key-internals.patch text/x-patch 1.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2023-12-22 12:29:58 Re: Transaction timeout
Previous Message Daniel Verite 2023-12-22 11:26:43 Re: Built-in CTYPE provider