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

Re: Cleaning up aborted transactions

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: Cleaning up aborted transactions
Date: 2003-06-10 11:49:03
Message-ID: 1055245742.56597.30.camel@jester (view raw or flat)
Thread:
Lists: pgsql-php
On Tue, 2003-06-10 at 05:21, Michael Glaesemann wrote:
> On Tuesday, Jun 10, 2003, at 17:05 Asia/Tokyo, Adrian Tineo wrote:
> > pg_connect($connection);
> > pg_query($connection,"BEGIN;");
> > $insert="INSERT INTO table VALUES (2,7,5);
> > $result=pg_query($connection,$insert);
> > if(!$result){
> >     pg_query($connection,"ROLLBACK");
> >     //Something went wrong with the insert so we rollback and nothing
> > changes in the db
> > }else{
> >     pg_query($connection,"COMMIT");
> >     // If everything went all right, then we commit the changes
> > }
> > pg_close($connection);
> 
> 
> Thanks, Adrian, for the illustration, especially the instance with 
> ROLLBACK. I've figured out this sequence now.
> 
> What I'm wondering about is what happens when this sequence isn't 
> properly followed and the script quits before issuing a ROLLBACK or a 
> COMMIT. Obviously it's not a good situation and one to be avoided.

The database, unless explicitly told to commit and the commit is
completely successful will always rollback.

So a disconnect results in a rollback.

-- 
Rod Taylor <rbt(at)rbt(dot)ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In response to

Responses

pgsql-php by date

Next:From: Rod TaylorDate: 2003-06-10 13:19:22
Subject: Re: Cleaning up aborted transactions
Previous:From: Greg SpiegelbergDate: 2003-06-10 11:39:16
Subject: Re: Cleaning up aborted transactions

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