Skip to content

pg_grammar_guard

Catalog-derived grammars and approved grammar drift checks

pg_grammar_guard · Catalog-derived grammars and approved grammar drift checks

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1890pg_grammar_guardpg_grammar_guard0.4.10RAGApache-2.0SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--NoNoNoYesnono
Relationships
Schemasgrammar_guard
Requirespg_living_assertions
Requires pg_living_assertions >= 0.5.9.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.4.1019 18 17 16 15pg_grammar_guardpg_living_assertions
RPMPIGSTY0.4.1019 18 17 16 15pg_grammar_guard_$vpg_living_assertions_$v
DEBPIGSTY0.4.1019 18 17 16 15postgresql-$v-pg-grammar-guardpostgresql-$v-pg-living-assertions
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.4.9PIGSTY 0.4.9PIGSTY 0.4.9PIGSTY 0.4.9
el8.aarch64N/APIGSTY 0.4.9PIGSTY 0.4.9PIGSTY 0.4.9PIGSTY 0.4.9
el9.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
el9.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
el10.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
el10.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
d12.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
d12.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
d13.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
d13.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u22.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u22.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u24.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u24.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u26.x86_64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
u26.aarch64PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10PIGSTY 0.4.10
PackageVersionOSORGSIZEFile URL
pg_grammar_guard_190.4.10el9.x86_64pigsty38.2 KiBpg_grammar_guard_19-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_190.4.10el9.aarch64pigsty38.2 KiBpg_grammar_guard_19-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_190.4.10el10.x86_64pigsty38.4 KiBpg_grammar_guard_19-0.4.10-1PGSTY.el10.noarch.rpm
pg_grammar_guard_190.4.10el10.aarch64pigsty38.4 KiBpg_grammar_guard_19-0.4.10-1PGSTY.el10.noarch.rpm
postgresql-19-pg-grammar-guard0.4.10d12.x86_64pigsty30.6 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-19-pg-grammar-guard0.4.10d12.aarch64pigsty30.6 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-19-pg-grammar-guard0.4.10d13.x86_64pigsty30.6 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-19-pg-grammar-guard0.4.10d13.aarch64pigsty30.6 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-19-pg-grammar-guard0.4.10u22.x86_64pigsty28.8 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-19-pg-grammar-guard0.4.10u22.aarch64pigsty28.8 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-19-pg-grammar-guard0.4.10u24.x86_64pigsty28.7 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-19-pg-grammar-guard0.4.10u24.aarch64pigsty28.7 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-19-pg-grammar-guard0.4.10u26.x86_64pigsty28.7 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
postgresql-19-pg-grammar-guard0.4.10u26.aarch64pigsty28.7 KiBpostgresql-19-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
PackageVersionOSORGSIZEFile URL
pg_grammar_guard_180.4.9el8.x86_64pigsty38.4 KiBpg_grammar_guard_18-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_180.4.9el8.aarch64pigsty38.4 KiBpg_grammar_guard_18-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_180.4.10el9.x86_64pigsty38.2 KiBpg_grammar_guard_18-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_180.4.10el9.aarch64pigsty38.2 KiBpg_grammar_guard_18-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_180.4.10el10.x86_64pigsty38.4 KiBpg_grammar_guard_18-0.4.10-1PGSTY.el10.noarch.rpm
pg_grammar_guard_180.4.10el10.aarch64pigsty38.4 KiBpg_grammar_guard_18-0.4.10-1PGSTY.el10.noarch.rpm
postgresql-18-pg-grammar-guard0.4.10d12.x86_64pigsty30.6 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-18-pg-grammar-guard0.4.10d12.aarch64pigsty30.6 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-18-pg-grammar-guard0.4.10d13.x86_64pigsty30.6 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-18-pg-grammar-guard0.4.10d13.aarch64pigsty30.6 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-18-pg-grammar-guard0.4.10u22.x86_64pigsty28.8 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-18-pg-grammar-guard0.4.10u22.aarch64pigsty28.8 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-18-pg-grammar-guard0.4.10u24.x86_64pigsty28.7 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-18-pg-grammar-guard0.4.10u24.aarch64pigsty28.7 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-18-pg-grammar-guard0.4.10u26.x86_64pigsty28.8 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
postgresql-18-pg-grammar-guard0.4.10u26.aarch64pigsty28.8 KiBpostgresql-18-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
PackageVersionOSORGSIZEFile URL
pg_grammar_guard_170.4.9el8.x86_64pigsty38.4 KiBpg_grammar_guard_17-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_170.4.9el8.aarch64pigsty38.4 KiBpg_grammar_guard_17-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_170.4.10el9.x86_64pigsty38.2 KiBpg_grammar_guard_17-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_170.4.10el9.aarch64pigsty38.2 KiBpg_grammar_guard_17-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_170.4.10el10.x86_64pigsty38.4 KiBpg_grammar_guard_17-0.4.10-1PGSTY.el10.noarch.rpm
pg_grammar_guard_170.4.10el10.aarch64pigsty38.4 KiBpg_grammar_guard_17-0.4.10-1PGSTY.el10.noarch.rpm
postgresql-17-pg-grammar-guard0.4.10d12.x86_64pigsty30.6 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-17-pg-grammar-guard0.4.10d12.aarch64pigsty30.6 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-17-pg-grammar-guard0.4.10d13.x86_64pigsty30.6 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-17-pg-grammar-guard0.4.10d13.aarch64pigsty30.6 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-17-pg-grammar-guard0.4.10u22.x86_64pigsty28.8 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-17-pg-grammar-guard0.4.10u22.aarch64pigsty28.8 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-17-pg-grammar-guard0.4.10u24.x86_64pigsty28.7 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-17-pg-grammar-guard0.4.10u24.aarch64pigsty28.7 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-17-pg-grammar-guard0.4.10u26.x86_64pigsty28.7 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
postgresql-17-pg-grammar-guard0.4.10u26.aarch64pigsty28.7 KiBpostgresql-17-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
PackageVersionOSORGSIZEFile URL
pg_grammar_guard_160.4.9el8.x86_64pigsty38.4 KiBpg_grammar_guard_16-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_160.4.9el8.aarch64pigsty38.4 KiBpg_grammar_guard_16-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_160.4.10el9.x86_64pigsty38.2 KiBpg_grammar_guard_16-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_160.4.10el9.aarch64pigsty38.2 KiBpg_grammar_guard_16-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_160.4.10el10.x86_64pigsty38.4 KiBpg_grammar_guard_16-0.4.10-1PGSTY.el10.noarch.rpm
pg_grammar_guard_160.4.10el10.aarch64pigsty38.4 KiBpg_grammar_guard_16-0.4.10-1PGSTY.el10.noarch.rpm
postgresql-16-pg-grammar-guard0.4.10d12.x86_64pigsty30.6 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-16-pg-grammar-guard0.4.10d12.aarch64pigsty30.6 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-16-pg-grammar-guard0.4.10d13.x86_64pigsty30.6 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-16-pg-grammar-guard0.4.10d13.aarch64pigsty30.6 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-16-pg-grammar-guard0.4.10u22.x86_64pigsty28.8 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-16-pg-grammar-guard0.4.10u22.aarch64pigsty28.8 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-16-pg-grammar-guard0.4.10u24.x86_64pigsty28.7 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-16-pg-grammar-guard0.4.10u24.aarch64pigsty28.7 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-16-pg-grammar-guard0.4.10u26.x86_64pigsty28.7 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
postgresql-16-pg-grammar-guard0.4.10u26.aarch64pigsty28.7 KiBpostgresql-16-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
PackageVersionOSORGSIZEFile URL
pg_grammar_guard_150.4.9el8.x86_64pigsty38.4 KiBpg_grammar_guard_15-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_150.4.9el8.aarch64pigsty38.4 KiBpg_grammar_guard_15-0.4.9-1PGSTY.el8.noarch.rpm
pg_grammar_guard_150.4.10el9.x86_64pigsty38.2 KiBpg_grammar_guard_15-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_150.4.10el9.aarch64pigsty38.2 KiBpg_grammar_guard_15-0.4.10-1PGSTY.el9.noarch.rpm
pg_grammar_guard_150.4.10el10.x86_64pigsty38.4 KiBpg_grammar_guard_15-0.4.10-1PGSTY.el10.noarch.rpm
pg_grammar_guard_150.4.10el10.aarch64pigsty38.4 KiBpg_grammar_guard_15-0.4.10-1PGSTY.el10.noarch.rpm
postgresql-15-pg-grammar-guard0.4.10d12.x86_64pigsty30.6 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-15-pg-grammar-guard0.4.10d12.aarch64pigsty30.6 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~bookworm_all.deb
postgresql-15-pg-grammar-guard0.4.10d13.x86_64pigsty30.6 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-15-pg-grammar-guard0.4.10d13.aarch64pigsty30.6 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~trixie_all.deb
postgresql-15-pg-grammar-guard0.4.10u22.x86_64pigsty28.8 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-15-pg-grammar-guard0.4.10u22.aarch64pigsty28.8 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~jammy_all.deb
postgresql-15-pg-grammar-guard0.4.10u24.x86_64pigsty28.7 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-15-pg-grammar-guard0.4.10u24.aarch64pigsty28.7 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~noble_all.deb
postgresql-15-pg-grammar-guard0.4.10u26.x86_64pigsty28.7 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb
postgresql-15-pg-grammar-guard0.4.10u26.aarch64pigsty28.7 KiBpostgresql-15-pg-grammar-guard_0.4.10-1PGSTY~resolute_all.deb

Source

github.com/Manuelreyesbravo/pg_grammar_guard

pig build pkg pg_grammar_guard;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_grammar_guard;		# install by package name

pig install pg_grammar_guard -v 19;   # install for PG 19
pig install pg_grammar_guard -v 18;   # install for PG 18
pig install pg_grammar_guard -v 17;   # install for PG 17
pig install pg_grammar_guard -v 16;   # install for PG 16
pig install pg_grammar_guard -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_grammar_guard CASCADE; -- requires pg_living_assertions

Usage

Sources:

pg_grammar_guard 0.4.10 creates GBNF or JSON Schema from catalog identifiers and watches approved grammars for drift. It is pure SQL and requires pg_living_assertions 0.5.6 or later (0.5.10 or later recommended).

Core Workflow

CREATE EXTENSION pg_grammar_guard CASCADE;
CREATE TABLE public.grammar_demo (id integer, label text);
SELECT grammar_guard.grammar_for_json(ARRAY[
  ROW('column', 'enum',
      grammar_guard.catalog_columns('public.grammar_demo'), true)
]::grammar_guard.grammar_field[]);

Operational Boundaries

grammar_guard.catalog_tables() and grammar_guard.catalog_columns() expose catalog names; grammar_guard.grammar_for_json() assembles typed fields, nested structures and bounded arrays. grammar_guard.watch() records the SQL that regenerates a grammar, and grammar_guard.check_grammar() compares it with the approved state in living_assertions.status. The generating query resolves with its author search path and executes as that author. Input NULLs, empty/duplicate field names, empty pivots and invalid bounds are rejected; max_items is capped at 1000. Version 0.4.8 changes canonical fingerprints, and the ordered catalog list can make an existing watch fail once: inspect and re-approve it. A grammar controls allowed tokens, not semantic correctness or authorization. Register trusted SQL only. No preload is required. Current Apache-2.0 licensing begins at 0.4.4; earlier releases retain their original license.

Current Compatibility

Version 0.4.10 updates documentation and tested compatibility without changing SQL objects. Upstream records PostgreSQL 11–19 coverage. The supplied 0.4.9-to-0.4.10 SQL update advances the extension version only; keep the earlier role and dependency requirements above.

Table reader