É possível criar uma transação atômica no PostgreSQL?
Considere que eu tenho uma categoria de tabela com estas linhas:
id|name
--|---------
1 |'tablets'
2 |'phones'
E o nome da coluna tem restrição exclusiva.
Se eu tentar:
BEGIN;
update "category" set name = 'phones' where id = 1;
update "category" set name = 'tablets' where id = 2;
COMMIT;
Estou entendendo:
ERROR: duplicate key value violates unique constraint "category_name_key"
DETAIL: Key (name)=(tablets) already exists.