How to install and use pgindent

pgindent maintains the uniform layout style of postgresql related source code.


I assume that (1) Postgres is installed in /usr/local/pgsql (2) PostgreSQL’s source code is located in/usr/local/src/postgresql

Details are described in src/tools/pgindent/README.

1. Install pg_bsd_indent

You can do the following operations anywhere.

$ git clone
$ cd pg_bsd_indent/
$ make PG_CONFIG=/usr/local/pgsql/bin/pg_config 
$ cp pg_bsd_indent /usr/local/bin

2. Install Perl-Tidy

You can do the following operations anywhere. Note that you must download version 20170521, don’t use other versions.

$ wget
$ tar xvfz Perl-Tidy-20170521.tar.gz 
$ cd Perl-Tidy-20170521
$ perl Makefile.PL 
$ make
$ make test
$ make install

3. Install typedefs

Change to the top of the source code tree, and issue the following wget command.

$ cd /usr/local/src/postgresql
$ wget -O src/tools/pgindent/typedefs.list


$ cd /usr/local/src/postgresql
$ ./src/tools/pgindent/pgindet

If you make an extension that is located in the contrib sub-directory, do the following command.

$ cd /usr/local/src/postgresql/contirb/your_extension
$ ../../src/tools/pgindent/pgindent