# pg_query_rewrite
`pg_query_rewrite` is a PostgreSQL extension which allows to translate a given source SQL statement into another pre-defined SQL statement.
# Installation
## Compiling
This module can be built using the standard PGXS infrastructure. For this to work, the pg_config program must be available in your $PATH:
`git clone https://github.com/pierreforstmann/pg_query_rewrite.git`
`cd pg_query_rewrite`
`make`
`make install`
## PostgreSQL setup
Extension must be loaded at server level with `shared_preload_libraries` parameter:
`shared_preload_libraries = 'pg_query_rewrite'`
Following SQL statement must be run in each database:
`create extension pg_query_rewrite;`
`pg_query_rewrite` has been successfully tested with PostgreSQL 9.5, 9.6, 10, 11, 12 and 13.
## Usage
`pg_query_rewrite` has a single GUC : `pg_query_rewrite.max_rules` which is the maximum number of SQL statements that can be translated.
This extension is enabled if the related library is loaded and if `pg_query_rewrite.max_rules` parameter is set.