Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 7C5389FB201 for ; Thu, 1 Mar 2007 07:30:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 98988-04 for ; Thu, 1 Mar 2007 07:29:34 -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.243]) by postgresql.org (Postfix) with ESMTP id 1F10F9FB1CA for ; Thu, 1 Mar 2007 07:30:00 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c24so344771ana for ; Thu, 01 Mar 2007 03:29:59 -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:references; b=BcohmKDWwpKK9ixpblz1eC8yVZcb0tQHY5pyA2QMSSPTkwRzxF69rmbC7rNGOedCA4OQ7sP2M4NF2NokpIwKWhxv2KvUuRzMHtCuuBhP60YNOdUZLvpIQ+xNjqw3rASsO5VSSXfFiFPeTHYHzQIG3JjthEDZeHyFd87G+Y/EKgQ= 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:references; b=aLTbfslvKYD2MxQRkRd1fxTEg5q9DHKWPBES8UIniAbqA5QcrvZ9b5iwjzuGPrYNqWNKUEizc4mfOytM0OxpWVac7jQLtKwHJT1RLtxvsZuxD57RHjgpqycgLDBcjtDOTp+E4bWqywKKYPCpoJeM2RVqlRYHF1IQj0jalupnzPg= Received: by 10.100.191.5 with SMTP id o5mr1335234anf.1172748598976; Thu, 01 Mar 2007 03:29:58 -0800 (PST) Received: by 10.100.165.1 with HTTP; Thu, 1 Mar 2007 03:29:58 -0800 (PST) Message-ID: Date: Thu, 1 Mar 2007 12:29:58 +0100 From: mikie To: pgsql-php@postgresql.org Subject: Re: transactions from PHP - double COMMIT required? In-Reply-To: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16269_17290190.1172748598843" References: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/3 X-Sequence-Number: 3715 ------=_Part_16269_17290190.1172748598843 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/3/1, Mihail Mihailov : > > Hi, > > I think you should use ROLLBACK if the query cannot be executed. > one can commit only results of the queries that work. > Try ROLLBACK statement. > > The thing is that when I try my transaction from psql console then the command ROLLBACK is being issued by the postgres server itself right after I close my transaction with COMMIT;. According to transaction logic and idea - if something goes wrong then the entire transaction is being cancelled by ROLLBACK - it is the server responsibility to rollback such transaction. Now, when I try to do some inserts within my transaction I don't know if they will fail or not. Eitherway I am closing my transaction with the COMMIT; command - is that correct way ? It works logically OK from within psql console (I start with BEGIN and then close my sql commands with commit) but it does not work this way from within PHP script. I believe there is some issue with PHP - I am not sure if PHP processor applies some changes to my query and thus ignores the commit command? -- Mike ------=_Part_16269_17290190.1172748598843 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

2007/3/1, Mihail Mihailov <Mihail.Mihailov@uta.fi>:
Hi,

I think you should use ROLLBACK if the query cannot be executed.
one can commit only results of the queries that work.
Try ROLLBACK statement.

The thing is that when I try my transaction from psql console then the command ROLLBACK is being issued by the postgres server itself right after I close my transaction with COMMIT;. According to transaction logic and idea - if something goes wrong then the entire transaction is being cancelled by ROLLBACK - it is the server responsibility to rollback such transaction.

Now, when I try to do some inserts within my transaction I don't know if they will fail or not. Eitherway I am closing my transaction with the COMMIT; command - is that correct way ?
It works logically OK from within psql console (I start with BEGIN and then close my sql commands with commit) but it does not work this way from within PHP script. I believe there is some issue with PHP - I am not sure if PHP processor applies some changes to my query and thus ignores the commit command?

--
Mike

------=_Part_16269_17290190.1172748598843--