PATCH: Report libpq version and configuration

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема PATCH: Report libpq version and configuration
Дата
Msg-id CAGRY4nybirHxTn2P9B_EY_dT3iMk+rPtGwBf_E1+v+-Eanr5sw@mail.gmail.com
обсуждение исходный текст
Ответы Re: PATCH: Report libpq version and configuration  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Re: PATCH: Report libpq version and configuration  (Abhijit Menon-Sen <ams@toroid.org>)
Список pgsql-hackers
The attached patches propose new interfaces for exposing more configuration and versioning information from libpq at runtime. They are to be used by applications to obtain finer grained information about libpq's configuration (SSL, GSSAPI, etc), to identify libpq binaries, and for applications that use libpq to report diagnostic information


Patch 0001 adds PQlibInfo(), which returns an array of key/value description items reporting on configuration like the full version string, SSL support, gssapi support, thread safety, default port and default unix socket path. This is for application use and application diagnostics. It also adds PQlibInfoPrint() which dumps PQlibInfo() keys/values to stdout. See the commit message in patch 0001 for details.


Patch 0002 exposes LIBPQ_VERSION_STR, LIBPQ_VERSION_NUM and LIBPQ_CONFIGURE_ARGS symbols in the dynamic symbol table. These can be accessed by a debugger even when the library cannot be loaded or executed, and unlike macros are available even in a stripped executable. So they can be used to identify a libpq binary found in the wild. Their storage is shared with PQlibInfo()'s static data, so they only cost three symbol table entries.

$ cp ./build/src/interfaces/libpq/libpq.so libpq.so.stripped
$ strip libpq.so.stripped
$ gdb -batch -ex 'p (int)LIBPQ_VERSION_NUM' -ex 'p (const char *)LIBPQ_VERSION_STR' -ex 'p (const char *)LIBPQ_CONFIGURE_ARGS' ./libpq.so.stripped
$1 = 140000
$2 = 0x285f0 "PostgreSQL 14devel on x86_64-pc-linux-gnu, ...."
$3 = 0x28660 " '--cache-file=config.cache-' '--prefix=/home/craig/pg/master' '--enable-debug' '--enable-cassert' '--enable-tap-tests' '--enable-dtrace' 'CC=/usr/lib64/ccache/gcc' 'CFLAGS=-Og -ggdb3' ..."



Patch 0003 allows libpq.so to be executed directly from the command line to print its version, configure arguments etc exactly as PQlibInfoPrint() would output them. This is only enabled on x64 linux for now but can be extended to other targets quite simply.

$  ./build/src/interfaces/libpq/libpq.so
VERSION_NUM: 140000
VERSION: PostgreSQL 14devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1), 64-bit
CONFIGURE_ARGS:  '--cache-file=config.cache-' '--prefix=/home/craig/pg/master' '--enable-debug' '--enable-cassert' '--enable-tap-tests' '--enable-dtrace' 'CC=/usr/lib64/ccache/gcc' 'CFLAGS=-Og -ggdb3' 'CPPFLAGS=' 'CPP=/usr/lib64/ccache/gcc -E'
USE_SSL: 0
ENABLE_GSS: 0
ENABLE_THREAD_SAFETY: 1
HAVE_UNIX_SOCKETS: 1
DEFAULT_PGSOCKET_DIR: /tmp
DEF_PGPORT: 5432
Вложения

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

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: Collation versioning
Следующее
От: Robert Haas
Дата:
Сообщение: Re: new heapcheck contrib module