Re: Does 'instead of delete' trigger support modification of OLD

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Eugen Konkov <kes-kes(at)yandex(dot)ru>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Does 'instead of delete' trigger support modification of OLD
Date: 2019-11-07 22:28:18
Message-ID: 20191107222818.GA18712@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

On Thu, Nov 7, 2019 at 04:26:55PM -0500, Bruce Momjian wrote:
> On Thu, Nov 7, 2019 at 11:24:29AM +0200, Eugen Konkov wrote:
> > >> As far as allowing DELETE to modify the trigger row for RETURNING, I am
> > >> not sure how much work it would take to allow that, but it seems like it
> > >> is a valid requite, and if so, I can add it to the TODO list.
> >
> > > Yes, Add please into TODO the feature to "allowing DELETE to modify the trigger row
> > > for RETURNING". Becuase, as I have described at first letter, without
> > > this the RETURNING rows **does not correspond actually deleted data**
> >
> > > Thank you.
>
> I have added a TODO item:
>
> Allow DELETE triggers to modify rows, for use by RETURNING

Thinking some more on this, I now don't think a TODO makes sense, so I
have removed it.

Triggers are designed to check and modify input data, and since DELETE
has no input data, it makes no sense. In the attached SQL script, you
can see that only the BEFORE INSERT trigger fires, so there is no way
even with INSERT to change what is passed after the write to RETURNING.
What you can do is to modify the returning expression, which is what I
have done for the last query --- hopefully that will help you.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

Attachment Content-Type Size
trigtest.sql application/x-sql 1.2 KB

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2019-11-07 22:36:17 Re: wal_sender_timeout / wal_receiver_timeout - seconds or milliseconds?
Previous Message Alvaro Herrera 2019-11-07 21:50:10 Re: The word "virgin" used incorrectly and probably better off replaced

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2019-11-07 22:28:24 Re: TestLib::command_fails_like enhancement
Previous Message Alvaro Herrera 2019-11-07 22:15:19 Re: log bind parameter values on error