Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Christoph Moench-Tegeder
## Rob Sargent (robjsarg...@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.



Sv: Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Andreas Joseph Krogh
På mandag 03. september 2018 kl. 23:43:46, skrev Rob Sargent <
robjsarg...@gmail.com >:


 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"?
 
No:
show server_version_num; 
 ┌┐
 │ server_version_num │
 ├┤
 │ 15 │
 └┘
 (1 row)
  
 
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andr...@visena.com 
www.visena.com 
 


 


Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Rob Sargent




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"?




Re: Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Alvaro Herrera
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 Herrerahttps://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Andreas Joseph Krogh
På mandag 03. september 2018 kl. 23:34:48, skrev Christoph Moench-Tegeder <
c...@burggraben.net >:
## Andreas Joseph Krogh (andr...@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
andr...@visena.com 
www.visena.com 
 


 


Sv: Re: How to get shorter SERVER_VERSION in psql-prompt?

2018-09-03 Thread Andreas Joseph Krogh
På mandag 03. september 2018 kl. 23:03:10, skrev Alvaro Herrera <
alvhe...@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
andr...@visena.com 
www.visena.com