Re: BUG #15170: PQtransactionStatus returns ACTIVE after Empty Commit

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: klaxian(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15170: PQtransactionStatus returns ACTIVE after Empty Commit
Date: 2018-04-24 23:10:22
Message-ID: 16961.1524611422@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> PQtransactionStatus() incorrectly returns PQTRANS_ACTIVE after committing an
> empty transaction block (ie. BEGIN and COMMIT without any other queries).

I do not see that here; for instance, the attached test program prints

Initial PQtransactionStatus: 0
PQtransactionStatus after BEGIN: 2
PQtransactionStatus after COMMIT: 0
PQtransactionStatus after BEGIN; COMMIT: 0

which is what I'd expect (0 is PQTRANS_IDLE, 2 is PQTRANS_INTRANS).
I'd only expect PQTRANS_ACTIVE if libpq thinks a query is still "in
flight", ie the server hasn't returned a command-complete message.

I speculate that either you or PHP have not waited for the commit
response to come back ... but without a concrete example to look at,
it's hard to say more.

regards, tom lane

Attachment Content-Type Size
trans-status-test.c text/x-c 1.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-04-24 23:22:01 Re: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When Using Substitution Parameter
Previous Message jake 2018-04-24 20:01:46 Re: BUG #15168: "pg_isready -d" effectively ignores given database name