X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 7CE5F30E3B1 for ; Tue, 10 Jun 2003 12:49:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 82682-09 for ; Tue, 10 Jun 2003 09:49:29 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 263F030E5D3 for ; Tue, 10 Jun 2003 09:49:28 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Tue, 10 Jun 2003 08:43:14 -0400 Received: from cranel.com (192.168.11.184 [192.168.11.184]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id MSTWBQCG; Tue, 10 Jun 2003 08:51:33 -0400 Message-ID: <3EE5C364.4050008@cranel.com> Date: Tue, 10 Jun 2003 07:39:16 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: Cleaning up aborted transactions References: <1055245742.56597.30.camel@jester> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/7 X-Sequence-Number: 2071 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@Cranel.com Cranel. Technology. Integrity. Focus.