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

Re: Cleaning up aborted transactions

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Greg Spiegelberg" <gspiegelberg(at)cranel(dot)com>,<pgsql-php(at)postgresql(dot)org>
Subject: Re: Cleaning up aborted transactions
Date: 2003-06-16 05:12:36
Message-ID: 08cb01c333c5$e71e1c70$6500a8c0@fhp.internal (view raw or flat)
Thread:
Lists: pgsql-php
PHP issues a ROLLBACK into every persistent connection before passing it to
the next process.

Chris

----- Original Message ----- 
From: "Greg Spiegelberg" <gspiegelberg(at)cranel(dot)com>
To: <pgsql-php(at)postgresql(dot)org>
Sent: Tuesday, June 10, 2003 7:39 PM
Subject: Re: [PHP] Cleaning up aborted transactions


> Hi all,
>
> Just so I have this straight, because I've been wondering the same,
> if someone on my web site does a SELECT and then clicks on the browser
> stop or gets click happy hitting one or many other links on the same
> web page then the 1st SELECT and all other interrupted SELECT's should
> get rolled back if each query starts with a BEGIN; because there is a
> disconnect.  Correct?
>
> What about with persistant connections?
>
> Greg
>
>
> Rod Taylor wrote:
> > 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.
> >
>
>
> -- 
> Greg Spiegelberg
>   Sr. Product Development Engineer
>   Cranel, Incorporated.
>   Phone: 614.318.4314
>   Fax:   614.431.8388
>   Email: gspiegelberg(at)Cranel(dot)com
> Cranel. Technology. Integrity. Focus.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>


In response to

pgsql-php by date

Next:From: angelo RigoDate: 2003-06-18 13:50:38
Subject: login script
Previous:From: Ardell DzakyDate: 2003-06-13 13:27:20
Subject: test, please delete

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