DELETE trigger, direct or indirect?

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: DELETE trigger, direct or indirect?
Date: 2023-02-16 13:23:27
Message-ID: CAFCRh-_aJjgHvjbE4OvNHMAWygdJAC026_rgGYj1kfTmB-EvJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi. This is a bit unusual. We have a foreign key between two tables, with
ON DELETE CASCADE, to preserve referential integrity. But we apparently
also need to preserve the severed reference (by natural key, i.e. its
name), to later on reconnect the two entities after-the-fact, should the
parent row re-appear later on (in the same transaction or not it still
unclear).

To achieve this weird requirement, I'd like to know if it is possible in an
ON DELETE trigger to know whether the deletion is coming from a
direct-DELETE in the "child table", or whether the deletion is coming from
the "parent table" CASCADEd to the child table.

Thanks, --DD

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-02-16 15:44:11 Re: Automatic aggressive vacuum on almost frozen table takes too long
Previous Message Rama Krishnan 2023-02-16 13:18:38 Vacuum full issue