Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 07FF29FBEC6 for ; Thu, 1 Mar 2007 13:25:43 -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 21805-04 for ; Thu, 1 Mar 2007 13:25:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from math.unl.edu.ar (math.unl.edu.ar [168.96.132.184]) by postgresql.org (Postfix) with ESMTP id F2D759FBF4E for ; Thu, 1 Mar 2007 13:25:29 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by math.unl.edu.ar (Postfix) with ESMTP id 7B91A7F36; Thu, 1 Mar 2007 14:25:28 -0300 (ART) X-Virus-Scanned: amavisd-new at math.unl.edu.ar Received: from math.unl.edu.ar ([127.0.0.1]) by localhost (mail.matematica [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QkAsr6wAIND0; Thu, 1 Mar 2007 14:25:24 -0300 (ART) Received: from [192.168.1.14] (webinterna.matematica [192.168.1.14]) by math.unl.edu.ar (Postfix) with ESMTP id 98B1B7F34; Thu, 1 Mar 2007 14:25:24 -0300 (ART) Message-ID: <45E70C9A.200@bugs.unl.edu.ar> Date: Thu, 01 Mar 2007 14:25:46 -0300 From: "Martin A. Marques" User-Agent: Mozilla Thunderbird 1.0.8-1.1.fc4 (X11/20060501) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mikie Cc: pgsql-php@postgresql.org Subject: Re: transactions from PHP - double COMMIT required? References: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> <45E6E75F.4020408@bugs.unl.edu.ar> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL, BAYES_50 X-Spam-Level: X-Archive-Number: 200703/15 X-Sequence-Number: 3727 mikie wrote: > 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. Try executing the query without the last commit, and afterwords execute another query with commit. I personaly don't like to mix diferent querys and comands in one pg_query() line. Also, I am more bound to using things like MDB2 or PDO, which makes life easier. BTW, if you have log_statments = 'all', could you see those logs to check if the commits are really getting to the server? Martín