Client application name - Mailing list pgsql-hackers

From Dave Page
Subject Client application name
Date
Msg-id 937d27e10910130802v4374b3eeq6d3aea31642e8b2a@mail.gmail.com
Whole thread Raw
Responses Re: Client application name
Re: Client application name
Re: Client application name
Re: Client application name
Re: Client application name
List pgsql-hackers
A useful feature found in other DBMSs such as MS SQL Server that has
been requested on these lists a few times, is the ability for a client
application to report its name to the server. This information may
then be presented in logs, activity reports and so on to aid debugging
and help the sysadmin/DBA see easily what activity is coming from
where on their server.

The attached patch is a first quick cut of the basic functionality to
do this. Currently, it makes the following changes:

- Adds a new userset GUC called application_name.
- Modifies psql to set application_name to 'psql' following connection
to an 8.5 or above server.
- Adds the application_name value to the CSV log output.
- Adds a new parameter %a to the log line prefix which is replaced by
the application_name value.
- Reports the application_name with the other session stats in shared memory.
- Adds application_name to the pg_stat_activity view and
pg_stat_get_activity(int) function.

Work to be done:

- Docs
- libpq modifications
- Set the application_name in pg_dump and pals.

My questions to the group are:

- Is my approach reasonable?
- What interface should I include in libpq?

On the second question, obviously the user can call SET to set a
value, as I've done for now in psql, however in other DBMSs, it may be
set in the connection string. My feeling would be to do that, and
possibly add PQsetApplicationName(PGconn *conn, char *name) and char
*PQapplicationName(PGconn *conn);. What do others think?

(Yes, I know I should technically discuss then code, but I was going
to do this as a pet project to dabble in the server code which I don't
do nearly often enough and figured I'd just send a WIP :-p ).

--
Dave Page
EnterpriseDB UK:   http://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: EvalPlanQual seems a tad broken
Next
From: Alvaro Herrera
Date:
Subject: Re: Client application name