From: | "Steve Petrie, P(dot)Eng(dot)" <apetrie(at)aspetrie(dot)net> |
---|---|
To: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
Cc: | "rob stone" <floriparob(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: *** QUESTION *** After successful 'BEGIN; ' command -- why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS? |
Date: | 2015-10-12 09:52:30 |
Message-ID: | 126389EC0D7A4C6C8937376D88F53EBD@Dell |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Daniel,
Thanks for your response.
Ahhh -- so after a successful query, the PHP program must keep executing
pg_get_result($cnx) until a NULL result is obtained !!
And ONLY THEN does transaction status transition from
PGSQL_TRANSACTION_ACTIVE to PGSQL_TRANSACTION_INTRANS.
OK -- makes sense to me -- I will change the code accordingly.
* * *
* * *
BTW -- this PostgreSQL newbie (bye bye mysql) is getting a nice warm fuzzy
feeling, about PostgreSQL and its amazingly helpful community :)
Best,
Steve
* * *
Steve Petrie, P.Eng.
ITS-ETO Consortium
Oakville, Ontario, Canada
(905) 847-3253
apetrie(at)aspetrie(dot)net
----- Original Message -----
From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Steve Petrie, P.Eng." <apetrie(at)aspetrie(dot)net>
Cc: "rob stone" <floriparob(at)gmail(dot)com>; <pgsql-general(at)postgresql(dot)org>
Sent: Monday, October 12, 2015 5:22 AM
Subject: Re: [GENERAL] *** QUESTION *** After successful 'BEGIN;' command --
why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS?
Steve Petrie, P.Eng. wrote:
> And yes, I am using pg_send_query(...) to execute the BEGIN; command, so
> as
> to get a result resource returned. (Please see my forthcoming emailed
> response to Adrian Klaver, wherein I provide the PHP source code that
> Adrian
> requests.)
After successfully calling pg_send_query($cnx, $query),
pg_transaction_status($cnx) will return PGSQL_TRANSACTION_ACTIVE
until the results have been collected by looping over pg_get_result($cnx).
This is for any query, not specifically $query="BEGIN".
Example:
<?php
if (pg_send_query($dbcnx, "BEGIN")) {
do {
$res=pg_get_result($dbcnx);
// error processing here
} while ($res);
echo pg_transaction_status($dbcnx);
?>
This will output 2, which corresponds to PGSQL_TRANSACTION_INTRANS
as expected.
OTOH if commenting the call to pg_get_result($dbcnx), then
it ouputs 1 (PGSQL_TRANSACTION_ACTIVE) as you mentioned.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
--
Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-10-12 12:25:22 | Re: Drop or alter column under load give ERROR #42804 structure of query does not match function result type: |
Previous Message | Daniel Verite | 2015-10-12 09:22:25 | Re: *** QUESTION *** After successful 'BEGIN;' command -- why PGSQL_TRANSACTION_ACTIVE and not PGSQL_TRANSACTION_INTRANS? |