pg_fsql
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_fsql | 1.1.0 | UTIL | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4110 | pg_fsql | No | Yes | No | Yes | No | No | fsql |
Release tag 1.1.0 still ships extension SQL version 1.0; shared_preload_libraries is optional and only needed for session-start GUC availability.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 1817161514 | pg_fsql | plpgsql |
| RPM | PIGSTY | 1.1.0 | 1817161514 | pg_fsql_$v | - |
| DEB | PIGSTY | 1.1.0 | 1817161514 | postgresql-$v-pg-fsql | - |
Build
You can build the RPM / DEB packages for pg_fsql using pig build:
Install
You can install pg_fsql directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources: README, control file
pg_fsql is a recursive SQL template engine for PostgreSQL. It combines a C-based placeholder renderer with PL/pgSQL template execution, hierarchical template composition, and optional SPI plan caching. The upstream project emphasizes that it does not require superuser privileges.
Quick Start
Catalog Tables
The extension installs two main catalog tables:
path is dot-separated and defines the template hierarchy.
Commands and Placeholders
The README documents six command types:
execto execute SQL and returnjsonbrefto redirect to another templateifto choose a child branchexec_tplto execute SQL and re-render the result as a templatemapto collect children into a JSON objectNULLfor text fragments inserted into parents
The renderer supports placeholders such as:
{d[key]}{d[key]!r}forquote_literal{d[key]!j}for JSONB literals{d[key]!i}forquote_identifier
The special key _self injects the full input JSON object.
Public API
The upstream public functions include:
fsql.run(path, data, debug)to execute a template treefsql.render(path, data)to preview rendered SQLfsql.tree(path)to inspect hierarchyfsql.explain(path, data)to trace expansionfsql.validate()to check templatesfsql.depends_on(path)to inspect dependenciesfsql.clear_cache()to free cached SPI plans
Hierarchical Example
Notes
The README lists PostgreSQL 14+ and plpgsql. The control file currently declares SQL extension version 1.0, even though the package task tracks release 1.1.0. No official release notes were published in the repository; the user-facing README still documents the same core API and behavior.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)