Re: Current Connection Information
От | Aleksander Alekseev |
---|---|
Тема | Re: Current Connection Information |
Дата | |
Msg-id | CAJ7c6TP2JV7ZBE7+DHu3aM6k-xOQdexOxSn=KOMfVwVnH9fTBA@mail.gmail.com обсуждение исходный текст |
Ответ на | Current Connection Information (Maiquel Grassi <grassi@hotmail.com.br>) |
Список | pgsql-hackers |
Hi, > It would be viable and appropriate to implement a unified function that provides important information about the currentconnection? > > Just an example: "Current Connection Informations". > > I implemented it in PL/pgSQL to demonstrate the idea, see on GitHub: > https://github.com/maiquelgrassi/DBA-toolkit/blob/main/cluster/dba_whoami_function.sql I believe one would typically do something like this: ``` select * from pg_stat_activity where pid = pg_backend_pid(); ``` On top of that psql can be configured to display useful information, e.g.: ``` $ cat ~/.psqlrc \timing on select (case when pg_is_in_recovery() then 'replica' else 'master' end) as master_or_replica \gset \set PROMPT1 '%p (%:master_or_replica:) =# ' ``` Personally I somewhat doubt that there is a one-size-fits-all equivalent of `whoami` for Postgres. E.g. one person would like to see a list of extensions available in the current database while for another this is redundant information. Even if we do this I don't think this should be a PL/pgSQL function but rather a \whoami command for psql. This solution however will leave users of DataGrip and similar products unhappy. -- Best regards, Aleksander Alekseev
В списке pgsql-hackers по дате отправления: