pg_grammar_guard
pg_grammar_guard : Catalog-derived grammars and approved grammar drift checks
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1890 | pg_grammar_guard | pg_grammar_guard | 0.4.1 |
RAG | PostgreSQL | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| ----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | grammar_guard |
| Requires | pg_living_assertions |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.4.1 |
18 17 16 15 14 | pg_grammar_guard |
pg_living_assertions |
| RPM | PIGSTY | 0.4.1 |
18 17 16 15 14 | pg_grammar_guard_$v |
pg_living_assertions_$v |
| DEB | PIGSTY | 0.4.1 |
18 17 16 15 14 | postgresql-$v-pg-grammar-guard |
postgresql-$v-pg-living-assertions |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| el8.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| el9.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| el9.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| el10.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| el10.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| d12.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| d12.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| d13.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| d13.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u22.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u22.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u24.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u24.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u26.x86_64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
| u26.aarch64 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 | PIGSTY 0.4.1 |
Source
github.com/Manuelreyesbravo/pg_grammar_guard
pg_grammar_guard-0.4.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
pg_grammar_guard generates GBNF or JSON Schema from catalog identifiers and detects drift from approved grammars. It is pure SQL, needs no preload and is packaged for PostgreSQL 14–18. Its control file requires pg_living_assertions.
Generate a grammar
The catalog helpers enumerate actual tables, columns and enum labels. Generation supports nested objects and bounded arrays; open-ended values such as arbitrary SQL or file paths need separate validation.
Detect changes
grammar_guard.watch() stores the query that rebuilds a grammar, and grammar_guard.check_grammar() evaluates it against the live catalog. Results and their age are available through living_assertions.status.
Register baseline SQL only through trusted administrators. A grammar limits valid identifiers; it cannot prove that a selected table, join or answer is semantically correct. Baselines from the old 0.2 series lack the original generating query and require manual re-approval when upgrading.