Re: NEW in after insert trugger contained incorrect data - Mailing list pgsql-general

From Brilliantov Kirill Vladimirovich
Subject Re: NEW in after insert trugger contained incorrect data
Date
Msg-id 5469BA11.40507@byterg.ru
Whole thread Raw
In response to Re: NEW in after insert trugger contained incorrect data  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List pgsql-general
Jim Nasby wrote on 11/15/2014 07:57 AM:

>
> Something else to consider: using FOUND to decide whether to INSERT vs
> UPDATE is a race condition: you can do the SELECT, someone else can then
> insert or delete, and then you attempt to do the wrong thing.
>
> To handle this correctly, you need an appropriate UNIQUE constraint or
> primary key, and to follow the pattern in table 40-2 at
> http://www.postgresql.org/docs/9.3/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
>
>
> If you don't, and you have concurrent activity you can end up losing
> data (and in the case of a DELETE after your SELECT, the data loss will
> be completely silent).


Hello, Jim!
Table trassa.cpu_load_stat have field id, it is a primary key.
I rewrite trigger with using loop, unfortunately thi not solve problem.

--
Best regards,
Brilliantov Kirill Vladimirovich



pgsql-general by date:

Previous
From: Pawel Veselov
Date:
Subject: documentation for lo_* functions
Next
From: Dmitriy Igrishin
Date:
Subject: Re: documentation for lo_* functions