This extension prohibit from executing TRUNCATE command on PostgreSQL. This repository is designed to show you how to create extensions using hooks, and this is part of the presentation material at the JPUG PostgreSQL Unconference. Presentation materials can be found here.
Download the source archive of pg_prohibit_truncate from here, and then build and install it.
$ cd pg_prohibit_truncate
$ make USE_PGXS=1 PG_CONFIG=/opt/pgsql-X.Y.Z/bin/pg_config
$ su
# make USE_PGXS=1 PG_CONFIG=/opt/pgsql-X.Y.Z/bin/pg_config install
# exit
You need to load pg_prohibit_truncate into PostgreSQL
$ vi postgresql.conf
shared_preload_libraries = 'pg_prohibit_truncate'
pg_prohibit_truncate is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.