Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Ben Morrow
At 12PM -0800 on 20/02/13 you (Sergey Konoplev) wrote: > On Wed, Feb 20, 2013 at 10:16 AM, Ben Morrow wrote: > >> If you got mixed up with plpgsql anyway what is the reason of making > >> this WITH query constructions instead of implementing everything in a > >> plpgsql trigger on DELETE on exp th

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Sergey Konoplev
On Wed, Feb 20, 2013 at 10:16 AM, Ben Morrow wrote: >> If you got mixed up with plpgsql anyway what is the reason of making >> this WITH query constructions instead of implementing everything in a >> plpgsql trigger on DELETE on exp then? > > I'm not sure what you mean. "exp" isn't a table, it's a

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Ben Morrow
At 8AM -0800 on 20/02/13 you (Sergey Konoplev) wrote: > On Wed, Feb 20, 2013 at 12:19 AM, Ben Morrow wrote: > > That's not reliable. A concurrent txn could insert a conflicting row > > between the update and the insert, which would cause the insert to fail > > with a unique constraint violation.

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Sergey Konoplev
On Wed, Feb 20, 2013 at 12:19 AM, Ben Morrow wrote: > That's not reliable. A concurrent txn could insert a conflicting row > between the update and the insert, which would cause the insert to fail > with a unique constraint violation. Okay I think I got it. The function catches exception when INS

Re: [SQL] Volatile functions in WITH

2013-02-20 Thread Ben Morrow
Quoth gray...@gmail.com (Sergey Konoplev): > On Sat, Feb 16, 2013 at 11:58 PM, Ben Morrow wrote: > > WITH "exp" AS ( -- as before > > ), > > "subst" AS ( > > SELECT add_item(e.basket, e.nref, e.count) > > FROM "exp" e > > WHERE e.nref IS NOT NULL > > ) > >