From: Adrian Klaver <adrian.klaver@aklaver.com>
To: PegoraroF10 <marcos@f10.com.br>
To: pgsql-general@postgresql.org
Subject: Re: Trigger bug ?
Date: Wed, 22 May 2019 15:42:35 -0700
Message-ID: <0514c201-42f8-2cf4-2325-015ef78f65bb@aklaver.com> (raw)
In-Reply-To: <1558563706827-0.post@n3.nabble.com>
References: <1558560792308-0.post@n3.nabble.com>
<baf9bba2-30c5-d1f4-0055-033b631fa365@aklaver.com>
<1558563706827-0.post@n3.nabble.com>
On 5/22/19 3:21 PM, PegoraroF10 wrote:
> sorry, I wasn´t clear, when I sad returning Null I tried to say that new.PK
> was Null, not the function result > Try to create exactly what I sent you and you´ll see null values on
that pk.
Yes because FOR EACH STATEMENT may deal with multiple rows, so it is
undefined what NEW.pk is referring to.
More below.
> And that occurs just because that trigger was created without EACH
> ROW/STATEMENT.
> So, my question is, PG should return an error and not create that trigger
> because ROW/STATEMENT was not specified, correct ?
It was implicitly specified. Per the docs it will be FOR EACH STATEMENT
by default in the absence of user input.
If you just need the new PK why not?:
INSERT INTO some_table ... RETURNING pk;
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.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: adrian.klaver@aklaver.com, marcos@f10.com.br
Subject: Re: Trigger bug ?
In-Reply-To: <0514c201-42f8-2cf4-2325-015ef78f65bb@aklaver.com>
References: <1558560792308-0.post@n3.nabble.com> <baf9bba2-30c5-d1f4-0055-033b631fa365@aklaver.com> <1558563706827-0.post@n3.nabble.com> <0514c201-42f8-2cf4-2325-015ef78f65bb@aklaver.com>
* 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