Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 414679FC028 for ; Thu, 1 Mar 2007 12:43:07 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 00759-03 for ; Thu, 1 Mar 2007 12:42:55 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.244]) by postgresql.org (Postfix) with ESMTP id E1E7A9FBFCB for ; Thu, 1 Mar 2007 12:42:54 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c24so409611ana for ; Thu, 01 Mar 2007 08:42:54 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=QuXgBZcgG97WpHOoi8IkhVbXY8az2OPXKtFAu58vr1ayp9AoQaKazMNXudVnGEleA9dbnc1ejCml95adY0daGBWcpmpJydSXLdcfyI5zlXePN46jInZbIysvBOfTgopHhkhkp269OXPsfrh+pw8yc6Bg++pw/Vb4wgIkLtNMqIo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=hbjNuWZWGvH/05adJvwKaZQz/8B+y1a6TGFWMf6y4lVeYnOmSzc75ntDZeu88mPE1UuUorY4ftQHVbSVkXi29yLXJBGkdKMMYyoa81Sjy8hvGin7G2rrW2822aeJLO/t0i0a2STHP0ZqXwAFrh5RM+v5a0x1Ot+Z6MymdavN7DU= Received: by 10.100.93.5 with SMTP id q5mr1574497anb.1172767374303; Thu, 01 Mar 2007 08:42:54 -0800 (PST) Received: by 10.100.165.1 with HTTP; Thu, 1 Mar 2007 08:42:54 -0800 (PST) Message-ID: Date: Thu, 1 Mar 2007 17:42:54 +0100 From: mikie To: pgsql-php@postgresql.org Subject: Re: transactions from PHP - double COMMIT required? In-Reply-To: <45E6E75F.4020408@bugs.unl.edu.ar> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> <45E6E75F.4020408@bugs.unl.edu.ar> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/13 X-Sequence-Number: 3725 2007/3/1, Martin Marques : > mikie wrote: > >> > But getting back to my problem - perhaps there is something I > >> > misunderstood: is it the client application responsibility to check if > >> > the transaction failed or succeeded and issue COMMIT or ROLLBACK > >> > accordingly (how do I close the transaction block in that case)? > >> > Or is it the database server that is suppose to check if transaction > >> > succeded and perform the query, or ROLLBACK if anything went wrong? > >> > >> PG will rollback all transactions that have an error in some part, as it > >> can't commit the transaction as a whole. > > > > OK, so my way of programming seems correct. > > Then why do I have to send another COMMIT after failed transaction to > > continue with next queries in the same php script ? > > I may not have gotten your question right, but with one commit (or end) > is enough. Transaction gets closed (commited or rolled back), and you > can start a new transaction with BEGIN. Thats exactly what I was thinking, too. But PHP does things in some other way, I guess. I am sending an entire sql transaction block to the PHP pg_query command, so it starts with BEGIN and ends with COMMIT. Then I still have to execute another pg_query with "commit;" only - thats why I am asking here if maybe someone know what the problem is.