pg_query_rewrite
Rewrite SQL statements with a PostgreSQL ProcessUtility hook
Repository
pierreforstmann/pg_query_rewrite
https://github.com/pierreforstmann/pg_query_rewrite
Source
pg_query_rewrite-0.0.5.tar.gz
pg_query_rewrite-0.0.5.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_query_rewrite | 0.0.5 | ADMIN | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 5030 | pg_query_rewrite | No | Yes | Yes | Yes | No | No | - |
| Related | pg_fsql ddlx pg_readme pglinter omni_sql pg_variables pre_prepare plan_filter pg_hint_plan pgdd |
|---|
Requires shared_preload_libraries=pg_query_rewrite.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.5 | 1817161514 | pg_query_rewrite | - |
| RPM | PIGSTY | 0.0.5 | 1817161514 | pg_query_rewrite_$v | - |
| DEB | PIGSTY | 0.0.5 | 1817161514 | postgresql-$v-pg-query-rewrite | - |
Build
You can build the RPM / DEB packages for pg_query_rewrite using pig build:
Install
You can install pg_query_rewrite directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Preload:
Create Extension:
Usage
Source: README
pg_query_rewrite rewrites an exact source SQL statement into a predefined target statement using rules stored in shared memory.
Required setup
Rule management
pgqr_add_rule(source, target): add a rewrite rule.pgqr_remove_rule(source): remove one rule.pgqr_truncate(): remove all rules.pgqr_rules(): inspect current shared-memory rules and rewrite counts.
Caveats
- Matching is exact: case, whitespace, and semicolons must match character-for-character.
- Parameterized SQL is not supported.
- Maximum statement length is hard-coded at 32 KB.
- Rules are not persisted; they vanish on restart unless you reapply them.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)