Search Postgresql Archives

Re: Server name in psql prompt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Morgan Lloyd wrote:
I thought earlier that I could use finger as a hack for querying the server, i.e. I could put e.g. a disc set name in /home/postgres/.plan. However I then realised that I'd need %M to be expanded before %`, so that I could do something like

\set PROMPT1 '`finger postgres@%M|filter`: %/%R%# '

where filter only returned the bit that was needed. I've not tried this due to the ordering issue.

I've just been playing with this. I can finger a fixed server for its "true name" using e.g.

postgres: markMLl=>
\set PROMPT1 '%`finger postgres@postgres|head -1|cut -d \[ -f 2|cut -d . -f 1`: %/%R%# '
postgres1: markMLl=>

but if I try to replace the fixed server name in that

\set PROMPT1 '%`finger postgres@%:HOST:|head...

the nested variable doesn't get expanded.

That's obviously useful if there's only one server or the servers are pooled since it means that the current disk set or whatever can be identified, but less so if there are multiple servers.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux