postgresql/src/tools/pgindent
Fujii Masao 40bede5477 Move pg_lzcompress.c to src/common.
The meta data of PGLZ symbolized by PGLZ_Header is removed, to make
the compression and decompression code independent on the backend-only
varlena facility. PGLZ_Header is being used to store some meta data
related to the data being compressed like the raw length of the uncompressed
record or some varlena-related data, making it unpluggable once PGLZ is
stored in src/common as it contains some backend-only code paths with
the management of varlena structures. The APIs of PGLZ are reworked
at the same time to do only compression and decompression of buffers
without the meta-data layer, simplifying its use for a more general usage.

On-disk format is preserved as well, so there is no incompatibility with
previous major versions of PostgreSQL for TOAST entries.

Exposing compression and decompression APIs of pglz makes possible its
use by extensions and contrib modules. Especially this commit is required
for upcoming WAL compression feature so that the WAL reader facility can
decompress the WAL data by using pglz_decompress.

Michael Paquier, reviewed by me.
2015-02-09 15:15:24 +09:00
..
README Improve pgindent test instructions 2014-05-06 15:33:38 -04:00
exclude_file_patterns Remove pgindent ecpg exclusion pattern 2014-05-06 20:09:31 -04:00
indent.bsd.patch Fix pg_bsd_indent bug where newlines were not being trimmed from typedef 2011-10-26 17:24:19 -04:00
perltidyrc Remove whitespace from end of lines 2013-05-30 21:05:07 -04:00
pgcppindent Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
pgindent pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgindent.man Fix whitespace issues found by git diff --check, add gitattributes 2013-11-10 14:48:29 -05:00
typedefs.list Move pg_lzcompress.c to src/common. 2015-02-09 15:15:24 +09:00

README

pgindent
========

This can format all PostgreSQL *.c and *.h files, but excludes *.y, and
*.l files.

1) Install pg_bsd_indent (see below for details).

2) Install entab (src/tools/entab/).

3) Change directory to the top of the build tree.

4) Remove all derived files (pgindent has trouble with one of the flex macros):

	make maintainer-clean

   Or:

	git clean -fdx

5) Download the typedef file from the buildfarm:

	wget -O src/tools/pgindent/typedefs.list http://buildfarm.postgresql.org/cgi-bin/typedefs.pl

6) Run pgindent:

	src/tools/pgindent/pgindent

7) Remove any files that generate errors and restore their original
   versions.

8) Indent the Perl code:

	(
		find . -name \*.pl -o -name \*.pm

		find . -type f -exec file {} \; |
		egrep -i ':.*perl[0-9]*\>' |
		cut -d: -f1
	) |
	sort -u |
	xargs perltidy --profile=src/tools/pgindent/perltidyrc

9) Do a full test build:

	> run configure
	# stop is only necessary if it's going to install in a location with an
	# already running server
	pg_ctl stop
	run configure
	make -C src install
	make -C contrib install
	run initdb
	pg_ctl start
	make installcheck-world

10) Remove Perl backup files after testing

---------------------------------------------------------------------------

BSD indent
----------

We have standardized on NetBSD's indent, and renamed it pg_bsd_indent.
We have fixed a few bugs which requre the NetBSD source to be patched
with indent.bsd.patch patch.  A fully patched version is available at
ftp://ftp.postgresql.org/pub/dev.

GNU indent, version 2.2.6, has several problems, and is not recommended.
These bugs become pretty major when you are doing >500k lines of code.
If you don't believe me, take a directory and make a copy.  Run pgindent
on the copy using GNU indent, and do a diff -r. You will see what I
mean. GNU indent does some things better, but mangles too.  For details,
see:

	http://archives.postgresql.org/pgsql-hackers/2003-10/msg00374.php
	http://archives.postgresql.org/pgsql-hackers/2011-04/msg01436.php

---------------------------------------------------------------------------

Notes about excluded files
--------------------------

src/include/storage/s_lock.h is excluded because it contains assembly code
that pgindent tends to mess up.

src/include/snowball/libstemmer/ and src/backend/snowball/libstemmer/
are excluded because those files are imported from an external project,
not maintained locally, and are machine-generated anyway.

src/interfaces/ecpg/test/expected/ is excluded to avoid breaking the ecpg
regression tests.  Several *.h files are included in regression output so
should not be changed.

---------------------------------------------------------------------------

Obsolete typedef list creation instructions
-------------------------------------------

To use pgindent:

1) Build the source tree with _debug_ symbols and all possible configure options

2) Install to /usr/local/pgsql

3) Install all contrib modules

4) Save a list of typedefs by running:

	src/tools/find_typedef /usr/local/pgsql/bin /usr/local/pgsql/lib > /tmp/pgtypedefs