From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Juliano Amaral Chaves <juliano(dot)amaral(at)hotmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Insert with query |
Date: | 2013-06-01 17:41:24 |
Message-ID: | 51AA3244.4050506@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 06/01/2013 09:22 AM, Kevin Grittner wrote:
> Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> wrote:
>> On 06/01/2013 06:47 AM, Kevin Grittner wrote:
>
>>> Currently on an AFTER ... FOR EACH ROW we fire the trigger once
>>> *for* each affected row, that's true. But we don't do it
>>> immediately after the *triggering event* -- we do it immediately
>>> after the *data change statement*. The issue isn't how many times
>>> we execute the trigger, or with what parameters, but *when* it
>>> runs.
>>
>> Aah, that was the part I was missing. So to see if I understand, in the
>> OPs case:
>>
>> 1) The first case worked as Juliano expected because the INSERTs where
>> done in a loop where each INSERT was a discrete statement and there was
>> a 1:1 correspondence between statement and triggering event.
>>
>> 2) The second case did not work as expected because the INSERTs where
>> wrapped up in a single statement and the AFTER triggers ran for each row
>> after all the rows where inserted not after each row was inserted.
>
> Exactly.
Hmm. I am going to have to pay more attention to how I move data when
using AFTER triggers, for instance using the single row vs multirow
forms of INSERT. Thanks for the explanation it was enlightening.
>
> --
> Kevin Grittner
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2013-06-01 21:27:28 | Re: Strange behavior of "=" as assignment operator |
Previous Message | Kevin Grittner | 2013-06-01 16:22:40 | Re: Insert with query |