Skip site navigation (1) Skip section navigation (2)

Re: what happens if something goes wrong in transaction?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: what happens if something goes wrong in transaction?
Date: 2008-02-28 15:13:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Thu, Feb 28, 2008 at 02:19:01PM +0000, A B wrote:
> Hi. newbie question, but what will happen if I do
> begin work;
> select ...
> insert ...
> and so on...
> commit
> and somewhere a query fails. will I get an automatic rollback?

After the error every subsequent statement will fail with "ERROR:
current transaction is aborted, commands ignored until end of
transaction block."  The transaction doesn't automatically end but
it will roll back even if you try to commit (assuming you didn't
do a partial rollback with SAVEPOINT/ROLLBACK TO).

> I'm using php to make all these calls and they have all to be succesfull or
> no one of them should be carried out.

That's the behavior you'll get if you use a transaction.  No changes
will be visible to other transactions until you successfully commit.

Michael Fuhr

In response to

pgsql-general by date

Next:From: DeeDate: 2008-02-28 15:18:43
Subject: beginner: what permissions required to install on windows 2000+
Previous:From: Michael FuhrDate: 2008-02-28 15:04:11
Subject: Re: beginner postgis question lat/lon

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group