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 9FE9E30DC6B for ; Tue, 10 Jun 2003 11:49:05 +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 84081-01 for ; Tue, 10 Jun 2003 08:48:55 -0300 (ADT) Received: from mailav.tor1.inquent.com (mail.inquent.com [216.208.117.106]) by svr1.postgresql.org (Postfix) with ESMTP id AFDDF30D6F4 for ; Tue, 10 Jun 2003 08:48:54 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mailav.tor1.inquent.com (Postfix) with ESMTP id 9C64A10258; Tue, 10 Jun 2003 07:42:55 -0400 (EDT) Received: from [192.168.1.200] (HSE-Toronto-ppp116801.sympatico.ca [216.209.81.112]) by mailav.tor1.inquent.com (Postfix) with ESMTP id 1729B10248; Tue, 10 Jun 2003 07:42:53 -0400 (EDT) Subject: Re: Cleaning up aborted transactions From: Rod Taylor To: Michael Glaesemann Cc: pgsql-php@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-9QgrjoDhMXyCpPOowDhI" Organization: Message-Id: <1055245742.56597.30.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 10 Jun 2003 07:49:03 -0400 X-Virus-Scanned: by AMaViS perl-11 X-Archive-Number: 200306/6 X-Sequence-Number: 2070 --=-9QgrjoDhMXyCpPOowDhI Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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=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 > > changes in the db > > }else{ > > pg_query($connection,"COMMIT"); > > // If everything went all right, then we commit the changes > > } > > pg_close($connection); >=20 >=20 > Thanks, Adrian, for the illustration, especially the instance with=20 > ROLLBACK. I've figured out this sequence now. >=20 > 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. The database, unless explicitly told to commit and the commit is completely successful will always rollback. So a disconnect results in a rollback. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-9QgrjoDhMXyCpPOowDhI 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+5cWu6DETLow6vwwRAmbgAJ9TIED2yqMD67mlE8sN02A27DQgjwCffeZa AZY1rbKCr7+GWM/dQ6gsDu4= =QxO9 -----END PGP SIGNATURE----- --=-9QgrjoDhMXyCpPOowDhI--