logo       

Re: transactions from PHP - double COMMIT required?: msg#00014

Subject: Re: transactions from PHP - double COMMIT required?
mikie wrote:
2007/3/1, Martin Marques <martin@xxxxxxxxxxxxxxx>:

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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe