Re: before insert for each row trigger on upsert

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ted Toth <txtoth(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: before insert for each row trigger on upsert
Date: 2020-02-20 21:43:09
Message-ID: d5c16b2d-1e84-249b-d9e5-e4e2221020a1@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/20/20 1:03 PM, Ted Toth wrote:
>
>
> On Thu, Feb 20, 2020 at 2:32 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
>
> On 2/20/20 12:17 PM, Ted Toth wrote:
> > I'm a little confused why the before insert trigger fires al all but
> > since it does is  there a way to know that an update will occur?
>
> Because ON CONFLICT DO UPDATE is part of an INSERT command.
>
> > Basically I don't want the trigger affect the row on update.
>
> Not sure that a BEFORE trigger will work for that anyway as it will not
> have submitted the data yet for ON CONFLICT resolution.
>
>
> 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.

Hard to say what to do without knowing what the trigger function
actually does?

>
>
> >
> > Ted
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roberto Della Pasqua 2020-02-20 22:09:30 spectrogram index?
Previous Message Adrian Klaver 2020-02-20 21:40:55 Re: How to fix 0xC0000005 exception in Postgres 9.0