Waiting for 9.6 – Add new system view, pg_config

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
LDFLAGS_EX = 
LDFLAGS_SL = 
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.