Re: Insert with query

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-05-31 13:56:38
Message-ID: 51A8AC16.3060209@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/31/2013 06:32 AM, Kevin Grittner wrote:
> Juliano Amaral Chaves <juliano(dot)amaral(at)hotmail(dot)com> wrote:
>
>> By doing insert into a table using a query, it seems that all
>> records of consultation were included bypassing the AFTER INSERT
>> triggers and as few as after all the records already included,
>> the TRIGGER is fired for each record, I wonder if this occurrence
>> is normal.
>>
>> I created an example that demonstrates my doubt, where the 1st
>> case works properly. The 2nd case is restricted by TRIGGER when I
>> think, that could not be
>
>> [ example showing that an AFTER INSERT trigger sees the modified
>> table as of the state after the INSERT statement completes,
>> rather than the state after the insert of the individual row ]
>
> I can see where that would be confusing, but things are operating
> as designed, AFAICS. The trigger fires after the statement, not
> after each affected row is processed.

But why? The OP specified FOR EACH ROW in the trigger statement.

>
> --
> Kevin Grittner
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2013-05-31 15:15:41 Re: Insert with query
Previous Message Albe Laurenz 2013-05-31 13:36:39 Re: Foreign Data Wrapper out of memory