pg_query_rewrite
Rewrite SQL statements with a PostgreSQL ProcessUtility hook
pg_query_rewrite : Rewrite SQL statements with a PostgreSQL ProcessUtility hook
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5030 | pg_query_rewrite | pg_query_rewrite | 0.0.5 |
ADMIN | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| See Also | 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.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.5 |
18 17 16 15 14 | pg_query_rewrite |
- |
| RPM | PIGSTY | 0.0.5 |
18 17 16 15 14 | pg_query_rewrite_$v |
- |
| DEB | PIGSTY | 0.0.5 |
18 17 16 15 14 | postgresql-$v-pg-query-rewrite |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| el8.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| el9.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| el9.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| el10.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| el10.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| d12.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| d12.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| d13.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| d13.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u22.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u22.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u24.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u24.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u26.x86_64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
| u26.aarch64 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 | PIGSTY 0.0.5 |
Source
github.com/pierreforstmann/pg_query_rewrite
pg_query_rewrite-0.0.5.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
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.