From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ted Toth <txtoth@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: before insert for each row trigger on upsert
Date: Thu, 20 Feb 2020 17:11:58 -0500
Message-ID: <27384.1582236718@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFPpqQHvynSRr4HX_a5tkqOBDat4zEk0a_fS+WPiJBLk8Uc_3A@mail.gmail.com>
References: <CAFPpqQH+6_mbJV2f5Nzm21Bg-G9GU_b91irDg+==y=6aMKgjVw@mail.gmail.com>
<18def70d-c2c4-ff92-b488-243ed0287001@aklaver.com>
<CAFPpqQHvynSRr4HX_a5tkqOBDat4zEk0a_fS+WPiJBLk8Uc_3A@mail.gmail.com>
Ted Toth <txtoth@gmail.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, txtoth@gmail.com, adrian.klaver@aklaver.com
Subject: Re: before insert for each row trigger on upsert
In-Reply-To: <27384.1582236718@sss.pgh.pa.us>
References: <CAFPpqQH+6_mbJV2f5Nzm21Bg-G9GU_b91irDg+==y=6aMKgjVw@mail.gmail.com> <18def70d-c2c4-ff92-b488-243ed0287001@aklaver.com> <CAFPpqQHvynSRr4HX_a5tkqOBDat4zEk0a_fS+WPiJBLk8Uc_3A@mail.gmail.com> <27384.1582236718@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox