pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mihail Mihailov <Mihail.Mihailov@uta.fi>
To: pgsql-php@postgresql.org
Subject: Re: transactions from PHP - double COMMIT required?
Date: Thu, 01 Mar 2007 13:15:23 +0200
Message-ID: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi> (raw)
In-Reply-To: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com>
References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com>

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.

Mihail


Quoting mikie <mikie.pl@gmail.com>:

> Hi,
>
> I  have this problem - after sending a query from PHP script with
> BEGIN-COMMIT transaction block that contains an error (e.g. I
> intentionally insert wrong data into the field of "date" type) I get
> an error (which is OK):ERROR:  date/time field value out of range.
>
> Now, when I try to DELETE or perform some other query later in the
> same PHP script  I receive this error:
> ERROR: current transaction is aborted, commands ignored until end of
> transaction block
>
> I am 100% sure that I have closed the transaction block with
> "COMMIT;". When I do the same in the console (psql) I get something
> like:
>
> BEGIN; INSERT INTO table1 (somecolumn) VALUES ('somedata');   
> INSERTsdf; COMMIT;
>
> I get this reply
> BEGIN
> INSERT 180610 1
> ERROR:  syntax error at or near "INSERTsdf" at character 1
> ROLLBACK
>
> Everything seems to be logical and works fine. So why this does not
> work from PHP? I figured one thing to workaround my problem: I am
> sending the query like this:
> BEGIN;
> (here are few insert queries, one is syntax error);
> COMMIT;
> Then I check the pg_result of this query in PHP, and if it is FALSE I
> have to send another simple query : "COMMIT;" - yes I know this is
> second commit already. But it works this way!
> It seems like if PHP ignored my COMMIT command from the transaction query.
> I also tried sending the transaction query like this:
> BEGIN;
> some queries;
> COMMIT;COMMIT;
> but this is not working. I need to send one transaction query, check
> if the result is false, then send another COMMIT.
>
> Any ideas where I got something missed?
>
> Regards,
> Mike
>
> ---------------------------(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



-- 
Mihail Mihailov, lehtori
Käännöstiede (venäjä)
Kieli- ja käännöstieteiden laitos
33014 Tampereen yliopisto
puh. (03) 3551 6123
sähköposti: mihail.mihailov@uta.fi



view thread (23+ messages)  latest in thread

Message-ID: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi>
Permalink:  ../20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi/
Also on:    postgresql.org/message-id/20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi

 · 

reply

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: Mihail.Mihailov@uta.fi
  Subject: Re: transactions from PHP - double COMMIT required?
  In-Reply-To: <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi>
  References: <ca35ce500703010306nd06dcfcy1247fb2b4297b0c2@mail.gmail.com> <20070301131523.fgfm83nb9y2kgo4c@imp3.uta.fi>

* 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