Re: Implicit transaction not rolling back after error

From: Stephen Touset <stephen(dot)touset(at)onelogin(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Implicit transaction not rolling back after error
Date: 2012-12-20 23:33:21
Message-ID: 7B4A64A0-6489-47AD-86EE-0BCC43D6AA23@onelogin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Dec 20, 2012, at 3:27 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> wrote:

> When on (the default), each SQL command is automatically committed upon successful completion. To postpone commit in this mode, you must enter a BEGIN or START TRANSACTION SQL command. When off or unset, SQL commands are not committed until you explicitly issue COMMIT or END. The autocommit-off mode works by issuing an implicit BEGIN for you, just before any command that is not already in a transaction block and is not itself a BEGIN or other transaction-control command, nor a command that cannot be executed inside a transaction block (such as VACUUM).
>
> Note: In autocommit-off mode, you must explicitly abandon any failed transaction by entering ABORT or ROLLBACK. Also keep in mind that if you exit the session without committing, your work will be lost.
> Note: The autocommit-on mode is PostgreSQL's traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you might wish to set it in the system-wide psqlrc file or your ~/.psqlrc file.

In this case, not only is AUTOCOMMIT set to "on", but I wasn't even able to turn it off for testing purposes.

test=# SET AUTOCOMMIT TO off;
ERROR: SET AUTOCOMMIT TO OFF is no longer supported

So yes, AUTOCOMMIT is definitely on.

--
Stephen Touset
Senior Software Engineer
stephen(dot)touset(at)onelogin(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Touset 2012-12-20 23:38:17 Re: Implicit transaction not rolling back after error
Previous Message Adrian Klaver 2012-12-20 23:27:15 Re: Implicit transaction not rolling back after error