Re: Get PG primary version without substring manipulation?

Поиск
Список
Период
Сортировка
От Keith Fiske
Тема Re: Get PG primary version without substring manipulation?
Дата
Msg-id CAODZiv7VKSjy9YxwWf4BYm3r8EqgaXcppQJi6FSSx_7zBfd6=g@mail.gmail.com
обсуждение исходный текст
Ответ на Get PG primary version without substring manipulation?  (Ron Johnson <ronljohnsonjr@gmail.com>)
Ответы Re: Get PG primary version without substring manipulation?
Список pgsql-admin


On Thu, Jun 13, 2024 at 8:52 AM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
cut, awk, head, bash, etc are easy enough,  but am I overlooking some intrinsic method of getting just PG's primary version number (9.6 or 14, in my case) without doing substring manipulation?

$ ssh foo.example.com pg_config --version
PostgreSQL 9.6.24
$ ssh foo.example.com psql --version
psql (PostgreSQL) 9.6.24
$ psql -h foo.example.com -Xtc "SELECT version();"
 PostgreSQL 9.6.24 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit

$ ssh bar.example.com pg_config --version
PostgreSQL 14.12
$ ssh bar.example.com psql --version
psql (PostgreSQL) 14.12
$ psql -h bar.example.com -Xtc "SELECT version();"
 PostgreSQL 14.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit




If you're logging into the database, I prefer getting the number value like this when using it for comparisons. Still need to do some manipulation if you just want the major version, but it's a lot easier to work with than the strings you were getting with other methods.

keith=# select current_setting('server_version_num')::int;
 current_setting
-----------------
          160002

--
Keith Fiske
Senior Database Engineer
Crunchy Data - http://crunchydata.com

В списке pgsql-admin по дате отправления:

Предыдущее
От: Peter Adlersburg
Дата:
Сообщение: Re: Get PG primary version without substring manipulation?
Следующее
От: J T
Дата:
Сообщение: Re: Get PG primary version without substring manipulation?