From: | rob stone <floriparob(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Igor Korot <ikorot01(at)gmail(dot)com> |
Cc: | John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, John R Pierce <pierce(at)hogranch(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Backward compatibility |
Date: | 2017-07-22 15:24:00 |
Message-ID: | 1500737040.4745.0.camel@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, 2017-07-22 at 10:49 -0400, Tom Lane wrote:
> Igor Korot <ikorot01(at)gmail(dot)com> writes:
> > But it works incorrectly - it should return:
> > 9.5.7 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 6.3.1
> > 20161221
> > (Red Hat 6.3.1-1), 64-bit
> > i.e. without the word "PosgreSQL", since '\s' should match the
> > (first)
> > space in the version().
>
> position() is not a regex operation, it's just a plain substring
> match.
>
> regression=# SELECT position( '\s' in version() ) ;
> position
> ----------
> 0
> (1 row)
>
> You hardly need any flexibility for this anyway, so I'd just do
>
> regression=# SELECT position( ' ' in version() ) ;
> position
> ----------
> 11
> (1 row)
>
> Although possibly what you really want is split_part().
>
> regression=# select split_part(version(), ' ', 2);
> split_part
> ------------
> 9.5.7
> (1 row)
>
> regards, tom lane
>
>
An alternative select:-
SELECT version(), (regexp_split_to_array( version(), E'\\s+'))[2]
Cheers,
Rob
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Korot | 2017-07-22 16:22:32 | Re: Backward compatibility |
Previous Message | Tom Lane | 2017-07-22 14:49:56 | Re: Backward compatibility |