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 C840F30E8C9 for ; Tue, 10 Jun 2003 13:19:26 +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 87371-05 for ; Tue, 10 Jun 2003 10:19:16 -0300 (ADT) Received: from mailav.tor1.inquent.com (mail.inquent.com [216.208.117.106]) by svr1.postgresql.org (Postfix) with ESMTP id 0C33B30E5EC for ; Tue, 10 Jun 2003 10:19:16 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mailav.tor1.inquent.com (Postfix) with ESMTP id F123B10258; Tue, 10 Jun 2003 09:13:13 -0400 (EDT) Received: from [10.0.2.8] (unknown [10.0.2.8]) by mailav.tor1.inquent.com (Postfix) with ESMTP id A33AA10248; Tue, 10 Jun 2003 09:13:11 -0400 (EDT) Subject: Re: Cleaning up aborted transactions From: Rod Taylor To: Greg Spiegelberg Cc: pgsql-php@postgresql.org In-Reply-To: <3EE5C364.4050008@cranel.com> References: <1055245742.56597.30.camel@jester> <3EE5C364.4050008@cranel.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-aIhhuNeeOTFi9tDwF9Th" Organization: Message-Id: <1055251161.91204.7.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 10 Jun 2003 09:19:22 -0400 X-Virus-Scanned: by AMaViS perl-11 X-Archive-Number: 200306/8 X-Sequence-Number: 2072 --=-aIhhuNeeOTFi9tDwF9Th Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-06-10 at 07:39, Greg Spiegelberg wrote: > Hi all, >=20 > 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 happens is up to PHP to decide in this case. If the browser disconnects from the webserver, thus PHP is interrupted, then yes, that sounds like what should happen. > What about with persistant connections? Persistent & pooled connections are managed by the client. It is up to PHP to determine what needs to happen. PHP should be resetting (rolling back) the connection when it re-enters into the pool, but the database has no knowledge that sharing is taking place. I'm not entirely sure. Haven't tried persistent connections since the early 3.x days. > Rod Taylor wrote: > > On Tue, 2003-06-10 at 05:21, Michael Glaesemann wrote: > >=20 > >>On Tuesday, Jun 10, 2003, at 17:05 Asia/Tokyo, Adrian Tineo wrote: > >> > >>>pg_connect($connection); > >>>pg_query($connection,"BEGIN;"); > >>>$insert=3D"INSERT INTO table VALUES (2,7,5); > >>>$result=3Dpg_query($connection,$insert); > >>>if(!$result){ > >>> pg_query($connection,"ROLLBACK"); > >>> //Something went wrong with the insert so we rollback and > >> > > nothing > >=20 > >>>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=20 > >>ROLLBACK. I've figured out this sequence now. > >> > >>What I'm wondering about is what happens when this sequence isn't=20 > >>properly followed and the script quits before issuing a ROLLBACK or a= =20 > >>COMMIT. Obviously it's not a good situation and one to be avoided. > >=20 > >=20 > > The database, unless explicitly told to commit and the commit is > > completely successful will always rollback. > >=20 > > So a disconnect results in a rollback. > >=20 --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-aIhhuNeeOTFi9tDwF9Th Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQA+5drZ6DETLow6vwwRAtGSAJ4k4E0pZOISLI1A1d87rOLNHkvzfQCZAWNu i7iDTtlBrC+M+NrzQtXQdn8= =cfQs -----END PGP SIGNATURE----- --=-aIhhuNeeOTFi9tDwF9Th--