Re: serialization errors
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ryan VanderBijl <rvbijl-pgsql@vanderbijlfamily.com>
Cc: pgsql-general@postgresql.org
Date: 2003-01-28T17:47:20Z
Lists: pgsql-general
Ryan VanderBijl <rvbijl-pgsql@vanderbijlfamily.com> writes: > There are many reasons that the INSERT statement could fail (e.g. syntax, > database connection dropped, conflicting concurrent update, unique constraint). An INSERT statement can *never* fail because of a concurrent conflicting update, because it isn't an update. Any INSERT is, logically speaking, creating a unique new entity (row) in the database; there is no conflict against other insertions, unless by way of violation of a unique constraint. > If I receive the legal error "duplicate key" error, how am I supposed to > detect if that error is due to a concurrent update, or because of some > other error elsewhere? What difference does it make if the other guy got there ten microseconds or ten years earlier? He inserted before you did. Whether it's "concurrent" or not shouldn't matter that I can see. Perhaps more to the point, there is no reason to expect that a duplicate-key failure will succeed if you retry the same insertion. regards, tom lane