From: | Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br> |
---|---|
To: | Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Psql meta-command conninfo+ |
Date: | 2024-02-09 09:18:44 |
Message-ID: | CP8P284MB2496D0B0946A4C55D7F0825EEC4B2@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Pavel!
>The patch v10 build ends with a warning:
>$ make -j --silent
>describe.c:911:1: warning: no previous prototype for ‘listConnectionInformation’ [-Wmissing-prototypes]
> 911 | listConnectionInformation()
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>About terms.
I resolved this in v11. I had forgotten to put
the 'void' inside the parentheses (describe.h and describe.c).
>postgres(at)postgres(17.0)=# \x \conninfo+
>Expanded display is on.
>Current Connection Information
>-[ RECORD 1 ]------+---------
>Database | postgres
>Authenticated User | postgres
>System User |
>Current User | postgres
>Session User | postgres
>Session PID | 951112
>Server Version | 17devel
>Server Address |
>Server Port | 5401
>Client Address |
>Client Port |
>Socket Directory | /tmp
>Host |
>It looks like "Session PID" is a new term for the server process identifier.
>How about changing the name to "Backend PID" (from pg_backend_pid) or even PID (from pg_stat_activity)?
You're right, it's better to stick with the proper terms already in use
in PostgreSQL. This ensures that the user doesn't get confused. I've
changed it to "Backend PID".
>On 08.02.2024 17:58, Maiquel Grassi wrote:
> 1.
> + if (db == NULL)
> + printf(_("You are currently not connected to a database.\n"));
>
> This check is performed for \conninfo, but not for \conninfo+.
1. The connection check for the case of \conninfo+ is handled by "describe.c" itself since it deals with queries. I might be mistaken, but I believe that by using "printQuery()" via "describe.c", this is already ensured, and there is no need to evaluate the connection status.
>I found that \conninfo and \conninfo+ act differently when the connection is broken.
>I used pg_terminate_backend function from another session to terminate an open psql session.
>After that, \conninfo does not see the connection break (surprisingly!), and \conninfo+ returns an error:
>postgres(at)postgres(17.0)=# \conninfo+
>FATAL: terminating connection due to administrator command
>server closed the connection unexpectedly
>This probably means the server terminated abnormally
>before or while processing the request.
>The connection to the server was lost. Attempting reset: Succeeded.
For this case, I believe it's already resolved, because if you get a
return indicating that the connection was terminated, and indeed it was,
then "describe.c" is handling it correctly. At least that's what
it seems like.
>postgres(at)postgres(17.0)=# \conninfo
>You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5401".
Here it seems like we have an issue to be studied and subsequently resolved.
>Another surprise is that this check: if (db == NULL) did not work in both cases.
I will investigate further and, if necessary, remove it.
Here's v12, in the next version, I'll try to address the above situation.
Thanks a lot!
Maiquel Grassi.
Attachment | Content-Type | Size |
---|---|---|
v12-0001-psql-meta-command-conninfo-plus.patch | application/octet-stream | 8.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2024-02-09 09:33:37 | Re: Reducing connection overhead in pg_upgrade compat check phase |
Previous Message | Anthonin Bonnefoy | 2024-02-09 09:09:43 | Fix parallel vacuum buffer usage reporting |