The world rejoiced as jdavis-pgsql@empires.org (Jeff Davis) wrote: > The problem is, when you add the first item to "cart_items" you have to > do an INSERT with a quantity of 1, but after that you need to do > UPDATEs. That would seem to create a potential race condition, so in > order for that to work it would seem you would need to do an ACCESS > EXCLUSIVE lock on the table to make sure no other process was reading > the table at the same time. Various sorts of race conditions are possible in multi-user multi-tasking systems; what _actual_ problem are you expecting to have here? What I would expect is that putting a unique index onto cart_items based on (cart_id, prod_id) would prevent getting the confusing situation of having multiple quantities of a single product in a single cart. I imagine that is the best thing to try to prevent, and that is readily done without any "locks" by adding a UNIQUE constraint. But perhaps I am imagining a different error condition. Can you describe the nature of the error condition that you are thinking about? That may help indicate what foreign key checks and/or uniqueness constraints might be worth adding. -- let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];; http://cbbrowne.com/info/internet.html This login session: only $23.95! ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org