Nested transactions in postgresql 8.2?
Well you have the possibility to use nested transactions inside postgresql using SavePoints.
Take this code example:
CREATE TABLE t1 (a integer PRIMARY KEY);CREATE FUNCTION test_exception() RETURNS boolean LANGUAGE plpgsql AS$$BEGIN INSERT INTO t1 (a) VALUES (1); INSERT INTO t1 (a) VALUES (2); INSERT INTO t1 (a) VALUES (1); INSERT INTO t1 (a) VALUES (3); RETURN TRUE;EXCEPTION WHEN integrity_constraint_violation THEN RAISE NOTICE 'Rollback to savepoint'; RETURN FALSE;END;$$;BEGIN;SELECT test_exception();NOTICE: Rollback to savepoint test_exception ---------------- f(1 row)COMMIT;SELECT count(*) FROM t1; count ------- 0(1 row)
Maybe this will help you out a little bit.
I've ended up 'solving' my problem out of band - I use a perl script to re-work the input scripts to eliminate their start transaction/commit calls, then push them all into one file, which gets it's own start transaction/commit.