From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Bruno Wolff III <bruno@wolff.to>
To: pgsql-general@postgresql.org
Subject: Re: Trying to understand odd trigger behavior
Date: Fri, 15 Jun 2018 08:54:52 +0200
Message-ID: <1529045692.3401.1.camel@cybertec.at> (raw)
In-Reply-To: <20180615040424.GA18759@wolff.to>
References: <20180615040424.GA18759@wolff.to>
Bruno Wolff III wrote:
> I think I know what is happening, but I wanted to see if my understanding
> is correct.
>
> I have a perl after insert trigger for a table with a non-null column element
> and I am getting an occasional error when the trigger executes for
> printing a null value which is $TD->{new}{element}. However, I do the
> insert with an on conflict that converts it into an update. And I have
> a before update trigger that blocks changing the record, but returns null
> if the old and new records are the same.
>
> My theory is that the insert trigger is firing even though the action
> got changed to an update and that because the update trigger cancelled
> the update, there is no new record. So I should just test for $TD->{new}
> being doing before doing stuff.
>
> Does that sound correct?
Absolutely, but it should be easy to run a few tests with only a single row
insert that confirms your theory.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
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: laurenz.albe@cybertec.at, bruno@wolff.to
Subject: Re: Trying to understand odd trigger behavior
In-Reply-To: <1529045692.3401.1.camel@cybertec.at>
References: <20180615040424.GA18759@wolff.to> <1529045692.3401.1.camel@cybertec.at>
* 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