Allow INSTEAD OF DELETE triggers to modify the tuple for RETURNING

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Allow INSTEAD OF DELETE triggers to modify the tuple for RETURNING
Date: 2016-07-01 00:12:56
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Currently the tuple returned by INSTEAD OF triggers on DELETEs is only
used to determine whether to pretend that the DELETE happened or not,
which is often not helpful enough; for example, the actual tuple might
have been concurrently UPDATEd by another transaction and one or more of
the columns now hold values different from those in the planSlot tuple.
Attached is an example case which is impossible to properly implement
under the current behavior. For what it's worth, the current behavior
seems to be an accident; before INSTEAD OF triggers either the tuple was
already locked (in case of BEFORE triggers) or the actual pre-DELETE
version of the tuple was fetched from the heap.

So I'm suggesting to change this behavior and allow INSTEAD OF DELETE
triggers to modify the OLD tuple and use that for RETURNING instead of
returning the tuple in planSlot. Attached is a WIP patch implementing that.

Is there any reason why we wouldn't want to change the current behavior?


Attachment Content-Type Size
instead_delete.sql text/plain 448 bytes
instead_delete_returning_v0.patch text/plain 5.3 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2016-07-01 00:27:03 Re: OpenSSL 1.1 breaks configure and more
Previous Message Michael Paquier 2016-06-30 23:50:38 Re: primary_conninfo missing from pg_stat_wal_receiver