template1=# create table foo(i int, j text); CREATE TABLE template1=# create unique index foo_idx on foo(i); CREATE INDEX template1=# begin; BEGIN template1=# insert into foo values(1, 'one'); INSERT 584714 1 template1=# select * from foo; i | j ---+----- 1 | one (1 row) template1=# savepoint sp1; SAVEPOINT template1=# insert into foo values(2, 'two'); INSERT 584715 1 template1=# insert into foo values(3, 'three'); INSERT 584716 1 template1=# select * from foo; i | j ---+------- 1 | one 2 | two 3 | three (3 rows) template1=# savepoint sp2; SAVEPOINT template1=# update foo set j = upper(j); UPDATE 3 template1=# select * from foo; i | j ---+------- 1 | ONE 2 | TWO 3 | THREE (3 rows) template1=# rollback to sp2; ROLLBACK template1=# select * from foo; i | j ---+--- (0 rows) template1=# abort; ROLLBACK template1=# select * from foo; i | j ---+--- (0 rows) template1=# drop table foo; DROP TABLE template1=# create table foo(i int, j text); CREATE TABLE template1=# insert into foo values(1, 'one'); INSERT 584722 1 template1=# drop table foo; DROP TABLE template1=# create table foo(i int, j text); CREATE TABLE template1=# begin; BEGIN template1=# insert into foo values(1, 'one'); INSERT 584728 1 template1=# select * from foo; i | j (1 row) template1=# savepoint sp1; SAVEPOINT template1=# insert into foo values(2, 'two'); INSERT 584729 1 template1=# insert into foo values(3, 'three'); INSERT 584730 1 template1=# select * from foo; i | j ---+------- 1 | one 2 | two 3 | three (3 rows) template1=# savepoint sp2; SAVEPOINT template1=# update foo set j = upper(j); UPDATE 3 template1=# select * from foo; i | j ---+------- 1 | ONE 2 | TWO 3 | THREE (3 rows) template1=# rollback to sp2; ROLLBACK template1=# select * from foo; i | j ---+------- 1 | one 2 | two 3 | three (3 rows)