Re: BEFORE ... Statement-level trigger - Mailing list pgsql-general

From Adrian Klaver
Subject Re: BEFORE ... Statement-level trigger
Date
Msg-id 6241dc72-4291-0713-1a3e-97b4f006e933@aklaver.com
Whole thread Raw
In response to BEFORE ... Statement-level trigger  (Jitendra Loyal <jitendra.loyal@gmail.com>)
Responses Re: BEFORE ... Statement-level trigger  (Jitendra Loyal <jitendra.loyal@gmail.com>)
List pgsql-general
On 2/18/19 9:11 AM, Jitendra Loyal wrote:
> I have gone through the documentation quite a number of times to 
> establish the understanding. However, I had been wondering about the 
> recursion in the case I put forth.
> 
> Is there a better way to handle this requirement? The point is that the 
> trigger is being called when no rows are affected.

Well as the docs say a FOR EACH STATEMENT trigger will execute in the 
absence of changed rows. So you have two options:

1) Use a FOR EACH ROW trigger.

2) Do what you did and include a sanity check.

Best guess is your AFTER STATEMENT trigger is tripping your BEFORE ROW 
trigger which then trips your AFTER STATEMENT and so on.

> 
> Thanks and regards,
> Jiten


-- 
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Statement-level trigger results in recursion
Next
From: Thomas Munro
Date:
Subject: Re: WSL (windows subsystem on linux) users will need to turn fsyncoff as of 11.2