February 29th, 2016 by depesz | Tags: , , , , , | No comments »
Did it help? If yes - maybe you can help me?

On 17th of February, Joe Conway committed patch:

Add new system view, pg_config
Move and refactor the underlying code for the pg_config client
application to src/common in support of sharing it with a new
system information SRF called pg_config() which makes the same
information available via SQL. Additionally wrap the SRF with a
new system view, as called pg_config.
Patch by me with extensive input and review by Michael Paquier
and additional review by Alvaro Herrera.

pg_config is not a tool used in everyday work, as it provides information that is related to compilation of PostgreSQL, like:

=$ pg_config 
BINDIR = /home/pgdba/work/bin
DOCDIR = /home/pgdba/work/share/doc/postgresql
HTMLDIR = /home/pgdba/work/share/doc/postgresql
INCLUDEDIR = /home/pgdba/work/include
PKGINCLUDEDIR = /home/pgdba/work/include/postgresql
INCLUDEDIR-SERVER = /home/pgdba/work/include/postgresql/server
LIBDIR = /home/pgdba/work/lib
PKGLIBDIR = /home/pgdba/work/lib/postgresql
LOCALEDIR = /home/pgdba/work/share/locale
MANDIR = /home/pgdba/work/share/man
SHAREDIR = /home/pgdba/work/share/postgresql
SYSCONFDIR = /home/pgdba/work/etc/postgresql
PGXS = /home/pgdba/work/lib/postgresql/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--prefix=/home/pgdba/work' '--enable-debug' '--with-pgport=5960' '--with-tcl' '--with-perl' '--with-python' '--enable-integer-datetimes' '--without-pam' '--without-bonjour' '--without-openssl' '--with-uuid=ossp' '--with-readline' '--with-libxml' '--with-zlib' '--with-gnu-ld'
CC = gcc
CPPFLAGS = -DFRONTEND -D_GNU_SOURCE -I/usr/include/libxml2
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2
CFLAGS_SL = -fpic
LDFLAGS = -L../../src/common -Wl,--as-needed -Wl,-rpath,'/home/pgdba/work/lib',--enable-new-dtags
LIBS = -lpgcommon -lpgport -lxml2 -lz -lreadline -lrt -lcrypt -ldl -lm  
VERSION = PostgreSQL 9.6devel

But it is nice in a way that it shows paths, and specific options that this PostgreSQL was compiled with.

And now, thanks to Joe, Michael, and Alvaro – we get this information also in form of sql view:

$ select * from pg_config order by 1;
       name        |                                                                                                                                       setting                                                                                                                                        
 BINDIR            | /home/pgdba/work/bin
 CC                | gcc
 CFLAGS            | -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2
 CFLAGS_SL         | -fpic
 CONFIGURE         | '--prefix=/home/pgdba/work' '--enable-debug' '--with-pgport=5960' '--with-tcl' '--with-perl' '--with-python' '--enable-integer-datetimes' '--without-pam' '--without-bonjour' '--without-openssl' '--with-uuid=ossp' '--with-readline' '--with-libxml' '--with-zlib' '--with-gnu-ld'
 CPPFLAGS          | -D_GNU_SOURCE -I/usr/include/libxml2
 DOCDIR            | /home/pgdba/work/share/doc/postgresql
 HTMLDIR           | /home/pgdba/work/share/doc/postgresql
 INCLUDEDIR        | /home/pgdba/work/include
 INCLUDEDIR-SERVER | /home/pgdba/work/include/postgresql/server
 LDFLAGS           | -L../../src/common -Wl,--as-needed -Wl,-rpath,'/home/pgdba/work/lib',--enable-new-dtags
 LDFLAGS_EX        | 
 LDFLAGS_SL        | 
 LIBDIR            | /home/pgdba/work/lib
 LIBS              | -lpgcommon -lpgport -lxml2 -lz -lreadline -lrt -lcrypt -ldl -lm  
 LOCALEDIR         | /home/pgdba/work/share/locale
 MANDIR            | /home/pgdba/work/share/man
 PGXS              | /home/pgdba/work/lib/postgresql/pgxs/src/makefiles/pgxs.mk
 PKGINCLUDEDIR     | /home/pgdba/work/include/postgresql
 PKGLIBDIR         | /home/pgdba/work/lib/postgresql
 SHAREDIR          | /home/pgdba/work/share/postgresql
 SYSCONFDIR        | /home/pgdba/work/etc/postgresql
 VERSION           | PostgreSQL 9.6devel
(23 rows)

I don't think it will be useful in day-to-day work, but I did stumble, couple of times, on cases where such information would be very helpful. So – thanks a lot guys, I appreciate it.

Leave a comment