BEGIN;
BEGIN
SELECT * FROM non_existing_table;
ERROR:  relation "non_existing_table" does not exist
LINE 1: SELECT * FROM non_existing_table;
                      ^
SELECT 1;
ERROR:  current transaction is aborted, commands ignored until end of transaction block
DETAIL:  statement: SELECT 1;
END;
ROLLBACK
BEGIN;
BEGIN
aaa;
ERROR:  syntax error at or near "aaa"
LINE 1: aaa;
        ^
SELECT 1;
ERROR:  current transaction is aborted, commands ignored until end of transaction block
DETAIL:  statement: SELECT 1;
END;
ROLLBACK
SELECT 1;
 ?column? 
----------
        1
(1 row)

BEGIN;
BEGIN
SAVEPOINT s1;
SAVEPOINT
aaa;
ERROR:  syntax error at or near "aaa"
LINE 1: aaa;
        ^
ROLLBACK TO s1;
ROLLBACK
SELECT 1;
 ?column? 
----------
        1
(1 row)

END;
COMMIT
CREATE TEMP TABLE t (id int UNIQUE);
CREATE TABLE
INSERT INTO t VALUES (1);
INSERT 0 1
BEGIN;
BEGIN
SAVEPOINT sp1;
SAVEPOINT
INSERT INTO t VALUES (1);
ERROR:  duplicate key value violates unique constraint "t_id_key"
DETAIL:  Key (id)=(1) already exists.
;
ROLLBACK TO SAVEPOINT sp1;
ROLLBACK
SELECT 'recovered' AS status;
  status   
-----------
 recovered
(1 row)

ROLLBACK;
ROLLBACK
