From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: akschoenberger@gmail.com
Subject: BUG #17824: PQTRANS_ACTIVE misleading
Date: Wed, 08 Mar 2023 04:01:30 +0000
Message-ID: <17824-c7bd094991e5f1c5@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 17824
Logged by: Andy Schoenberger
Email address: akschoenberger@gmail.com
PostgreSQL version: 15.2
Operating system: All
Description:
The documentation for PQTRANS_ACTIVE [1] does not make explicitly clear that
it is returned in *all* cases where there is a command in progress on an
okay connection, and not just in the case that there is a command in
progress inside of a transaction [2]. With a name like PQTRANS_ACTIVE, I
believe it is worth making clear that it can happen when a transaction is
not active. I believe this has led to multiple bugs in other programs that
attempt to display the current status of a transaction, including a possible
one in psql [3].
Assuming I am understanding everything correctly, I think the documentation
should probably be updated to make clear that PQTRANS_ACTIVE does not mean
that a transaction is active.
Best,
Andy
[1]
From:
https://www.postgresql.org/docs/15/libpq-status.html#LIBPQ-PQTRANSACTIONSTATUS> Returns the current in-transaction status of the server.
> The status can be PQTRANS_IDLE (currently idle), PQTRANS_ACTIVE (a command
is in progress), PQTRANS_INTRANS (idle, in a valid transaction block), or
PQTRANS_INERROR (idle, in a failed transaction block). PQTRANS_UNKNOWN is
reported if the connection is bad. PQTRANS_ACTIVE is reported only when a
query has been sent to the server and not yet completed.
[2]
https://github.com/postgres/postgres/blob/d69cd3a2e29c68a3fdfd4e97167f9a7c6ad29e80/src/interfaces/li...
[3]
The psql documentation below shows that a `*` character is present when a
transaction is active:
From:
https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-PROMPTING> Transaction status: an empty string when not in a transaction block, or *
when in a transaction block, or ! when in a failed transaction block, or ?
when the transaction state is indeterminate (for example, because there is
no connection).
…but a `*` character is also technically used if the transaction status is
PQTRANS_ACTIVE, which does not necessarily happen during a transaction.
https://github.com/postgres/postgres/blob/46d490ac19a7ca93a5c0f47e5a0e759b5385a8ae/src/bin/psql/prom...
I’m not sure if this is actually considered a bug or not since I don’t think
psql displays a new prompt until after the command completes, but the logic
in the code being misleading does not help.
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, akschoenberger@gmail.com
Subject: Re: BUG #17824: PQTRANS_ACTIVE misleading
In-Reply-To: <17824-c7bd094991e5f1c5@postgresql.org>
* 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