Re: [SQL] Atomicity of UPDATE, interchanging values in unique column

2003-03-08 Thread daniel alvarez
> The first is what you want. PostgreSQL needs some work in the > evaluation of unique indexes to properly support it. > > Namely, when it sees a conflict when inserting into the index, it needs > to record the fact, and revisit the conflict at the end of the command. > Lots of work... OK. The

Re: [SQL] Atomicity of UPDATE, interchanging values in unique column

2003-03-08 Thread Rod Taylor
> UPDATE sometable SET unique_col = >CASE WHEN unique_col = firstvalue THEN secondvalue > ELSE firstvalue >END > WHERE unique_col = firstvalue > OR unique_col = secondvalue (See last comment) > BEGIN; > SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; > > UPDATE sometabl

[SQL] Atomicity of UPDATE, interchanging values in unique column

2003-03-08 Thread daniel alvarez
UPDATE statements are not completely atomic in that index entries are updated separately for each row. A query interchanging two values within a column declared UNIQUE will fail due to the attempt of inserting a duplicate temporarily. It seems like Postgres validates constraints on indexes each ti