pg_relation_sql
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_relation_sql | 0.2.2 | UTIL | PostgreSQL | PLpgSQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4210 | pg_relation_sql | No | No | No | No | No | No | - |
| Related | pg_readme pg_dbms_metadata pg_get_functiondef pg_rewrite pg_query_rewrite ddl_historization data_historization |
|---|
Upstream intentionally ships no control file or CREATE EXTENSION path; execute the packaged relation_sql.sql in each database; relation_sql(‘install’) requires superuser only for its optional event trigger.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.2.2 | 1817161514 | pg_relation_sql | - |
| RPM | PIGSTY | 0.2.2 | 1817161514 | pg_relation_sql_$v | - |
| DEB | PIGSTY | 0.2.2 | 1817161514 | postgresql-$v-pg-relation-sql | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.2.2 el8.x86_64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.x86_64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.x86_64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.x86_64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.x86_64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el8.noarch.rpm
|
| el8.aarch64 | PIGSTY 0.2.2 el8.aarch64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.aarch64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.aarch64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.aarch64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el8.noarch.rpm
| PIGSTY 0.2.2 el8.aarch64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el8.noarch.rpm
|
| el9.x86_64 | PIGSTY 0.2.2 el9.x86_64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.x86_64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.x86_64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.x86_64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.x86_64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el9.noarch.rpm
|
| el9.aarch64 | PIGSTY 0.2.2 el9.aarch64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.aarch64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.aarch64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.aarch64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el9.noarch.rpm
| PIGSTY 0.2.2 el9.aarch64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el9.noarch.rpm
|
| el10.x86_64 | PIGSTY 0.2.2 el10.x86_64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.x86_64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.x86_64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.x86_64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.x86_64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el10.noarch.rpm
|
| el10.aarch64 | PIGSTY 0.2.2 el10.aarch64.pg18 : pg_relation_sql_18 pg_relation_sql_18-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.aarch64.pg17 : pg_relation_sql_17 pg_relation_sql_17-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.aarch64.pg16 : pg_relation_sql_16 pg_relation_sql_16-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.aarch64.pg15 : pg_relation_sql_15 pg_relation_sql_15-0.2.2-1PGSTY.el10.noarch.rpm
| PIGSTY 0.2.2 el10.aarch64.pg14 : pg_relation_sql_14 pg_relation_sql_14-0.2.2-1PGSTY.el10.noarch.rpm
|
| d12.x86_64 | PIGSTY 0.2.2 d12.x86_64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.x86_64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.x86_64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.x86_64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.x86_64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
|
| d12.aarch64 | PIGSTY 0.2.2 d12.aarch64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.aarch64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.aarch64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.aarch64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
| PIGSTY 0.2.2 d12.aarch64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~bookworm_all.deb
|
| d13.x86_64 | PIGSTY 0.2.2 d13.x86_64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.x86_64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.x86_64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.x86_64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.x86_64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
|
| d13.aarch64 | PIGSTY 0.2.2 d13.aarch64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.aarch64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.aarch64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.aarch64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
| PIGSTY 0.2.2 d13.aarch64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~trixie_all.deb
|
| u22.x86_64 | PIGSTY 0.2.2 u22.x86_64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.x86_64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.x86_64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.x86_64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.x86_64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
|
| u22.aarch64 | PIGSTY 0.2.2 u22.aarch64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.aarch64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.aarch64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.aarch64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
| PIGSTY 0.2.2 u22.aarch64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~jammy_all.deb
|
| u24.x86_64 | PIGSTY 0.2.2 u24.x86_64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.x86_64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.x86_64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.x86_64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.x86_64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
|
| u24.aarch64 | PIGSTY 0.2.2 u24.aarch64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.aarch64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.aarch64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.aarch64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
| PIGSTY 0.2.2 u24.aarch64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~noble_all.deb
|
| u26.x86_64 | PIGSTY 0.2.2 u26.x86_64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.x86_64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.x86_64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.x86_64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.x86_64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
|
| u26.aarch64 | PIGSTY 0.2.2 u26.aarch64.pg18 : postgresql-18-pg-relation-sql postgresql-18-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.aarch64.pg17 : postgresql-17-pg-relation-sql postgresql-17-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.aarch64.pg16 : postgresql-16-pg-relation-sql postgresql-16-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.aarch64.pg15 : postgresql-15-pg-relation-sql postgresql-15-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
| PIGSTY 0.2.2 u26.aarch64.pg14 : postgresql-14-pg-relation-sql postgresql-14-pg-relation-sql_0.2.2-1PGSTY~resolute_all.deb
|
Build
You can build the RPM / DEB packages for pg_relation_sql using pig build:
Install
You can install pg_relation_sql directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
This extension does not require
CREATE EXTENSION
Usage
Sources:
- pg_relation_sql 0.2.2 on PGXN
- pg_relation_sql 0.2.2 README
- pg_relation_sql 0.2.2 SQL script
- pg_relation_sql 0.2.2 plan comparison
pg_relation_sql 0.2.2 generates pairs of SQL functions from PostgreSQL foreign keys: a lookup follows a reference, while a list function returns rows that point back. The generated LANGUAGE sql functions are designed to be inlined by the planner, allowing queries to navigate declared relations without repeating join conditions.
Upstream deliberately ships one standalone relation_sql.sql file rather than a control file. There is no CREATE EXTENSION pg_relation_sql; execute the packaged script in every database where the functions are needed.
The script creates relation_sql(text) in the current schema and finishes by requesting relation_sql('install').
Generate and Use Relations
For each foreign key, the lookup function follows the referenced row and the reverse function uses a _list suffix unless the foreign key is one-to-one. Composite and cross-schema foreign keys are supported, and several foreign keys to the same target receive role-specific names.
Generator Modes
relation_sql()returns a status dashboard.relation_sql('show')reports the computed functions and ready-to-run synchronization commands without changing objects.relation_sql('sync')creates, replaces, or removes marked relation functions to match current foreign keys.relation_sql('install')adds addl_command_endevent trigger and synchronizes immediately.relation_sql('uninstall')removes the event trigger;relation_sql('drop')removes generated functions.
Operational Boundaries
- Creating the event trigger requires superuser privileges. Without them, installation emits a warning and the one-time synchronization still runs with the caller’s object privileges.
- Install the generator in a trusted schema with a controlled
search_path: automatic mode creates aSECURITY DEFINERevent-trigger helper that preserves the installation-time path. - Generated functions depend on table row types. Dropping a table whose row type is used by them can require
CASCADE; inspect dependencies before destructive DDL. - The generated bodies use
SELECT *, so column-levelSELECTgrants do not combine cleanly with them. Row-level security continues to apply. - Put relation functions in
FROMfor plan-sensitive queries. Attribute notation in a select list becomes aProjectSet, andNOT EXISTS (SELECT FROM relation_function(row))can remain a correlated probe instead of becoming the equivalent anti-join. - Queries depend on generated functions just as they depend on views. Run
relation_sql('sync')in the migration path when not using the event trigger. - Upstream requires PostgreSQL 11 or later; Pigsty packages cover PostgreSQL 14–18.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)