$ psql -h 127.0.0.1 -p 5432 -d postgres -U postgres -f txn_control_in_plpgsql_proc.sql ------------------------------------------------------------ Setup. ------------------------------------------------------------ Test p1() with AUTOCOMMIT off n ---- 17 n --- ------------------------------------------------------------ Test p1() with AUTOCOMMIT on n ---- 17 Expect "WARNING: there is no transaction in progress" psql:txn_control_in_plpgsql_proc.sql:79: WARNING: there is no transaction in progress ------------------------------------------------------------ Test p2() with AUTOCOMMIT on. Works only in this mode. Else "ERROR: invalid transaction termination" from the first "rollback" statement. psql:txn_control_in_plpgsql_proc.sql:95: NOTICE: isolation level #1: repeatable read psql:txn_control_in_plpgsql_proc.sql:95: NOTICE: isolation level #2: serializable n ---- 42 $