pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSv: Re: How to get shorter SERVER_VERSION in psql-prompt?
5+ messages / 4 participants
[nested] [flat]
* Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?
@ 2018-09-03 21:39 Andreas Joseph Krogh <andreas@visena.com>
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Joseph Krogh @ 2018-09-03 21:39 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-general@lists.postgresql.org
På mandag 03. september 2018 kl. 23:03:10, skrev Alvaro Herrera <
alvherre@2ndquadrant.com <mailto:alvherre@2ndquadrant.com>>:
On 2018-Sep-03, Andreas Joseph Krogh wrote:
> Hi all, I'm using the Ubuntu-packages and have this in my .psqlrc:
>
> \set PROMPT1 '%[%033[35m%]%n@%m:%>%[%033[0m%] %:server_version:
> %[%033[32m%]%/%[%033[0m%]%R%# '
>
> This results in this verver_version:
> 10.5 (Ubuntu 10.5-1.pgdg18.04+1)
>
> Is it possible to adjust this somehow so it outputs only "10.5"?
Well, where does that server_version come from? Try adding this
somewhere to .psqlrc:
select setting as server_version from pg_settings where name =
'server_version' \gset
select setting as server_version from pg_settings where name =
'server_version';
┌──────────────────────────────────┐
│ server_version │
├──────────────────────────────────┤
│ 10.5 (Ubuntu 10.5-1.pgdg18.04+1) │
└──────────────────────────────────┘
(1 row)
I use packages from http://apt.postgresql.org/pub/repos/apt/
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas@visena.com <mailto:andreas@visena.com>
www.visena.com <https://www.visena.com;
<https://www.visena.com;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?
@ 2018-09-03 21:41 Andreas Joseph Krogh <andreas@visena.com>
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Joseph Krogh @ 2018-09-03 21:41 UTC (permalink / raw)
To: Christoph Moench-Tegeder <cmt@burggraben.net>; +Cc: pgsql-general@lists.postgresql.org
På mandag 03. september 2018 kl. 23:34:48, skrev Christoph Moench-Tegeder <
cmt@burggraben.net <mailto:cmt@burggraben.net>>:
## Andreas Joseph Krogh (andreas@visena.com):
> This results in this verver_version:
> 10.5 (Ubuntu 10.5-1.pgdg18.04+1)
>
> Is it possible to adjust this somehow so it outputs only "10.5"?
On Debian/Ubuntu, all version strings are somewhat extended.
Luckily, with the power of SQL we're not completely helpless, so try
this in your .psqlrc (somewhat simpler than your prompt, but you
get the idea):
select substring(current_setting('server_version') from '#"[^ ]+#"( +%)?' for
'#') as short_server_ver\gset
\set PROMPT1 '%/ %:short_server_ver: %R%# '
Yes, that works across \c.
Nice, thanks!
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas@visena.com <mailto:andreas@visena.com>
www.visena.com <https://www.visena.com;
<https://www.visena.com;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?
@ 2018-09-03 21:42 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Andreas Joseph Krogh <andreas@visena.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alvaro Herrera @ 2018-09-03 21:42 UTC (permalink / raw)
To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org
On 2018-Sep-03, Andreas Joseph Krogh wrote:
> select setting as server_version from pg_settings where name =
> 'server_version';
> ┌──────────────────────────────────┐
> │ server_version │
> ├──────────────────────────────────┤
> │ 10.5 (Ubuntu 10.5-1.pgdg18.04+1) │
> └──────────────────────────────────┘
Ugh. (So this is coming from "configure --with-extra-version" stuff)
I guess you could just split it out at the first whitespace ...
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?
@ 2018-09-03 21:43 Rob Sargent <robjsargent@gmail.com>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Rob Sargent @ 2018-09-03 21:43 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 09/03/2018 03:42 PM, Alvaro Herrera wrote:
> On 2018-Sep-03, Andreas Joseph Krogh wrote:
>
>> select setting as server_version from pg_settings where name =
>> 'server_version';
>> ┌──────────────────────────────────┐
>> │ server_version │
>> ├──────────────────────────────────┤
>> │ 10.5 (Ubuntu 10.5-1.pgdg18.04+1) │
>> └──────────────────────────────────┘
> Ugh. (So this is coming from "configure --with-extra-version" stuff)
>
> I guess you could just split it out at the first whitespace ...
>
Does that also diddle the value of "server_version_num"?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?
@ 2018-09-03 21:46 Christoph Moench-Tegeder <cmt@burggraben.net>
parent: Rob Sargent <robjsargent@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Moench-Tegeder @ 2018-09-03 21:46 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
## Rob Sargent (robjsargent@gmail.com):
> > Ugh. (So this is coming from "configure --with-extra-version" stuff)
> Does that also diddle the value of "server_version_num"?
No, that's still integer-format (it's unchanged and you can cast it
straight into INTEGER).
Gruss,
Christoph
--
Spare Space.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-09-03 21:46 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03 21:39 Sv: Re: How to get shorter SERVER_VERSION in psql-prompt? Andreas Joseph Krogh <andreas@visena.com>
2018-09-03 21:42 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-09-03 21:43 ` Rob Sargent <robjsargent@gmail.com>
2018-09-03 21:46 ` Christoph Moench-Tegeder <cmt@burggraben.net>
2018-09-03 21:41 Sv: Re: How to get shorter SERVER_VERSION in psql-prompt? Andreas Joseph Krogh <andreas@visena.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox