Re: [GENERAL] Weird insert issue

2015-06-28 Thread Larry Meadors
Thanks for the clarification guys! That was not the behavior I was expecting (as you can tell), so I learned something new today. :) In my case I don't want an update (there are only the 2 fields, so it's just insert or delete), so I'll fire the insert as it is (that'll get the cases where it's no

Re: [GENERAL] Weird insert issue

2015-06-27 Thread Pavel Stehule
2015-06-28 6:52 GMT+02:00 Peter Geoghegan : > On Sat, Jun 27, 2015 at 9:47 PM, Pavel Stehule > wrote: > > you can protect it against this issue with locking - in this case you can > > try "for update" clause > > > > http://www.postgresql.org/docs/9.4/static/explicit-locking.html > > > > insert in

Re: [GENERAL] Weird insert issue

2015-06-27 Thread Peter Geoghegan
On Sat, Jun 27, 2015 at 9:47 PM, Pavel Stehule wrote: > you can protect it against this issue with locking - in this case you can > try "for update" clause > > http://www.postgresql.org/docs/9.4/static/explicit-locking.html > > insert into Favorite (patronId, titleId) > select 123, 234 > where not

Re: [GENERAL] Weird insert issue

2015-06-27 Thread Pavel Stehule
2015-06-28 6:37 GMT+02:00 Larry Meadors : > I'm running this SQL statement: > > insert into Favorite (patronId, titleId) > select 123, 234 > where not exists ( > select 1 from Favorite where patronId = 123 and titleId = 234 > ) > > It normally runs perfectly, but will rarely fail and I just can'