Re: COMMIT after an ERROR? - Mailing list pgsql-general

From Nathan Clemons
Subject Re: COMMIT after an ERROR?
Date
Msg-id Pine.LNX.4.33L2.0110121455290.28356-100000@sunrise.windsofstorm.net
Whole thread Raw
In response to COMMIT after an ERROR?  (J C Lawrence <claw@kanga.nu>)
List pgsql-general
On Fri, 12 Oct 2001, J C Lawrence wrote:

>
> Does an error during a transaction invalidate the transaction?
>
> eg
>
>   BEGIN
>   SomeQueryThatSucceeds
>   SomeQueryThatFails
>   SomeOtherQueryThatSucceeds
>   COMMIT
>
> Will the transaction successfully COMMIT, or will the COMMIT fail?
>
> Translation: Do I need to monitor for error conditions during a
> transaction and manually do the ROLLBACK in those cases?
>
>

Hey JC...

What will happen is:

BEGIN WORK;
--> BEGIN
SELECT * FROM sometable;
--> (select results)
INSERT INTO sometable VALUES (blah);
--> insert fails, gives error
UPDATE sometable SET somefield=somedata WHERE somecondition=somepattern;
--> NOTICE: transaction is in error, will not continue

If you COMMIT WORK or ABORT WORK, either way it will close the transaction
which is in an errored state and automatically rollback the changes.

--Nathan


pgsql-general by date:

Previous
From: Hervé Piedvache
Date:
Subject: Vacuum analyze with 7 millions records ... takes 1 hour !
Next
From: Bruce Momjian
Date:
Subject: Re: Joining Between Databases