mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add psql PROMPT variable showing the pid of the connected to backend.
The substitution for the pid is %p. Author: Julien Rouhaud Discussion: 116262CF971C844FB6E793F8809B51C6E99D48@BPXM02GP.gisp.nec.co.jp
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
* %M - database server "hostname.domainname", "[local]" for AF_UNIX
|
||||
* sockets, "[local:/dir/name]" if not default
|
||||
* %m - like %M, but hostname only (before first dot), or always "[local]"
|
||||
* %p - backend pid
|
||||
* %> - database server port number
|
||||
* %n - database user name
|
||||
* %/ - current database
|
||||
@ -161,6 +162,15 @@ get_prompt(promptStatus_t status)
|
||||
if (pset.db)
|
||||
strlcpy(buf, session_username(), sizeof(buf));
|
||||
break;
|
||||
/* backend pid */
|
||||
case 'p':
|
||||
if (pset.db)
|
||||
{
|
||||
int pid = PQbackendPID(pset.db);
|
||||
if (pid)
|
||||
snprintf(buf, sizeof(buf), "%d", pid);
|
||||
}
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
|
Reference in New Issue
Block a user