From: Martin A. Marques <martin@bugs.unl.edu.ar>
To: mikie <mikie.pl@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: transactions from PHP - double COMMIT required?
Date: Thu, 01 Mar 2007 14:25:46 -0300
Message-ID: <45E70C9A.200@bugs.unl.edu.ar> (raw)
In-Reply-To: <ca35ce500703010842v193a90cavdf8052330482ee9a@mail.gmail.com>
References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com>
<20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi>
<ca35ce500703010329j329b8a5h6ee8958ddb6711e0@mail.gmail.com>
<e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com>
<ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com>
<Pine.LNX.4.64.0703010948200.606@bugs.unl.edu.ar>
<ca35ce500703010502j77327b1bn9ca679e9dea38df9@mail.gmail.com>
<45E6E75F.4020408@bugs.unl.edu.ar>
<ca35ce500703010842v193a90cavdf8052330482ee9a@mail.gmail.com>
mikie wrote:
> 2007/3/1, Martin Marques <martin@bugs.unl.edu.ar>:
>
>> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: martin@bugs.unl.edu.ar, mikie.pl@gmail.com
Subject: Re: transactions from PHP - double COMMIT required?
In-Reply-To: <45E70C9A.200@bugs.unl.edu.ar>
References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com> <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> <ca35ce500703010329j329b8a5h6ee8958ddb6711e0@mail.gmail.com> <e0b20d410703010418m3f931527wb2e81e3f3ab0c9f4@mail.gmail.com> <ca35ce500703010445n67ca6714id0b10b393859f8e0@mail.gmail.com> <Pine.LNX.4.64.0703010948200.606@bugs.unl.edu.ar> <ca35ce500703010502j77327b1bn9ca679e9dea38df9@mail.gmail.com> <45E6E75F.4020408@bugs.unl.edu.ar> <ca35ce500703010842v193a90cavdf8052330482ee9a@mail.gmail.com> <45E70C9A.200@bugs.unl.edu.ar>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox