Re: before insert for each row trigger on upsert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ted Toth <txtoth(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: before insert for each row trigger on upsert
Date: 2020-02-20 22:11:58
Message-ID: 27384.1582236718@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ted Toth <txtoth(at)gmail(dot)com> writes:
> I think you are right in that the trigger doesn't change the row being
> updated (which is good) but it also updates another table and that's what
> I'd actually like to avoid on update.

Probably need to put that in an AFTER trigger, then. By definition,
BEFORE triggers don't really know whether the insert is going to
happen. This doesn't even require use of upsert to cause a problem:
a later BEFORE trigger could prevent the insertion, or change what
gets inserted.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2020-02-20 22:29:58 Re: How to fix 0xC0000005 exception in Postgres 9.0
Previous Message Roberto Della Pasqua 2020-02-20 22:09:30 spectrogram index?