pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: Michael Glaesemann <grzm@myrealbox.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Cleaning up aborted transactions
Date: 10 Jun 2003 07:49:03 -0400
Message-ID: <1055245742.56597.30.camel@jester> (raw)
In-Reply-To: <DB8E9D12-9B24-11D7-94FB-0005029FC1A7@myrealbox.com>
References: <DB8E9D12-9B24-11D7-94FB-0005029FC1A7@myrealbox.com>

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@rbt.ca>

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

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (8+ messages)  latest in thread

Message-ID: <1055245742.56597.30.camel@jester>
Permalink:  ../1055245742.56597.30.camel@jester/
Also on:    postgresql.org/message-id/1055245742.56597.30.camel@jester

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: rbt@rbt.ca, grzm@myrealbox.com
  Subject: Re: Cleaning up aborted transactions
  In-Reply-To: <1055245742.56597.30.camel@jester>
  References: <DB8E9D12-9B24-11D7-94FB-0005029FC1A7@myrealbox.com> <1055245742.56597.30.camel@jester>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox