pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #17824: PQTRANS_ACTIVE misleading
3+ messages / 3 participants
[nested] [flat]
* BUG #17824: PQTRANS_ACTIVE misleading
@ 2023-03-08 04:01 PG Bug reporting form <noreply@postgresql.org>
2023-03-08 16:22 ` Re: BUG #17824: PQTRANS_ACTIVE misleading David G. Johnston <david.g.johnston@gmail.com>
2023-03-08 16:22 ` Re: BUG #17824: PQTRANS_ACTIVE misleading Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: PG Bug reporting form @ 2023-03-08 04:01 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: akschoenberger@gmail.com
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17824: PQTRANS_ACTIVE misleading
2023-03-08 04:01 BUG #17824: PQTRANS_ACTIVE misleading PG Bug reporting form <noreply@postgresql.org>
@ 2023-03-08 16:22 ` David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: David G. Johnston @ 2023-03-08 16:22 UTC (permalink / raw)
To: akschoenberger@gmail.com; pgsql-bugs@lists.postgresql.org
On Wed, Mar 8, 2023 at 8:28 AM PG Bug reporting form <noreply@postgresql.org>
wrote:
> 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.
It is not possible for the server to execute a command without there being
an active transaction in progress.
> …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.
>
Right, it is difficult to report on/see the implicit transaction that
occurs if you send a command to the server without constructing an explicit
transaction block, since it goes away as the command execution ends.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17824: PQTRANS_ACTIVE misleading
2023-03-08 04:01 BUG #17824: PQTRANS_ACTIVE misleading PG Bug reporting form <noreply@postgresql.org>
@ 2023-03-08 16:22 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2023-03-08 16:22 UTC (permalink / raw)
To: akschoenberger@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> writes:
> 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.
The existing documentation defines it as "a command is in progress",
which seems perfectly clear to me --- adding more words would just
muddy the waters.
Also, if a command is running then the server *does* have a transaction
open -- it might be an auto-started, auto-committed one, but there's
always a transaction. You seem to be using that word in a way that does
not correspond with common Postgres usage. (Note that the definitions for
PQTRANS_INTRANS and PQTRANS_INERROR say "transaction block" not
"transaction", to comport with our usual terminology.)
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-03-08 16:22 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 04:01 BUG #17824: PQTRANS_ACTIVE misleading PG Bug reporting form <noreply@postgresql.org>
2023-03-08 16:22 ` David G. Johnston <david.g.johnston@gmail.com>
2023-03-08 16:22 ` Tom Lane <tgl@sss.pgh.pa.us>
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