> 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
> 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
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