Re: Trigger violates foreign key constraint

From: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, 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-25 09:03:16
Message-ID: e6a7c792-4cc4-45da-8a6e-6f6d74a3897d@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22.12.2023 14:39, Laurenz Albe wrote:
> Yes, that is better - shorter and avoids passive mode. Changed.

Thanks.

>> 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.

I still think that the "this is not a bug" style is not suitable for
documentation.
But I checked the documentation and found 3-4 more such places.
Therefore, it's ok from me, especially since it really looks like a bug.
> 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.

Yes, referential integrity will be maintained. But perhaps
it is worth adding a section to the documentation about system triggers
that are used to implement foreign keys. Now it is not mentioned anywhere,
but questions and problems arise from time to time.
Such a section named "System triggers" may be added as a separate chapter
to Part VII. Internals or as a subsection to Chapter 38.Triggers.

I thought about this after your recent excellent article [1],
which has an introduction to system triggers.

This does not negate the need for the patch being discussed.

> Patch v3 is attached.

For me, it is ready for committer.

1. https://www.cybertec-postgresql.com/en/broken-foreign-keys-postgresql/

--
Pavel Luzanov
Postgres Professional:https://postgrespro.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Vatsa 2023-12-25 10:18:24 Proposal to include --exclude-extension Flag in pg_dump
Previous Message Anton A. Melnikov 2023-12-25 08:23:27 Re: May be BUG. Periodic burst growth of the checkpoint_req counter on replica.