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

ID Extension Package Version Category License Language
1890 pg_grammar_guard pg_grammar_guard 0.4.9 RAG Apache-2.0 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
Requires pg_living_assertions >= 0.5.9.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.4.9 18 17 16 15 14 pg_grammar_guard pg_living_assertions
RPM PIGSTY 0.4.9 18 17 16 15 14 pg_grammar_guard_$v pg_living_assertions_$v
DEB PIGSTY 0.4.9 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
Package Version OS ORG SIZE File URL
pg_grammar_guard_18 0.4.1 el8.x86_64 pigsty 27.6 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_18 0.4.1 el8.aarch64 pigsty 27.6 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_18 0.4.1 el9.x86_64 pigsty 27.3 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_18 0.4.1 el9.aarch64 pigsty 27.2 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_18 0.4.1 el10.x86_64 pigsty 27.4 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el10.noarch.rpm
pg_grammar_guard_18 0.4.1 el10.aarch64 pigsty 27.3 KiB pg_grammar_guard_18-0.4.1-1PGSTY.el10.noarch.rpm
postgresql-18-pg-grammar-guard 0.4.1 d12.x86_64 pigsty 21.4 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-18-pg-grammar-guard 0.4.1 d12.aarch64 pigsty 21.4 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-18-pg-grammar-guard 0.4.1 d13.x86_64 pigsty 21.4 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-18-pg-grammar-guard 0.4.1 d13.aarch64 pigsty 21.4 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u22.x86_64 pigsty 22.1 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u22.aarch64 pigsty 22.1 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u24.x86_64 pigsty 22.0 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u24.aarch64 pigsty 22.0 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u26.x86_64 pigsty 22.0 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
postgresql-18-pg-grammar-guard 0.4.1 u26.aarch64 pigsty 22.0 KiB postgresql-18-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
Package Version OS ORG SIZE File URL
pg_grammar_guard_17 0.4.1 el8.x86_64 pigsty 27.6 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_17 0.4.1 el8.aarch64 pigsty 27.6 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_17 0.4.1 el9.x86_64 pigsty 27.3 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_17 0.4.1 el9.aarch64 pigsty 27.2 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_17 0.4.1 el10.x86_64 pigsty 27.4 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el10.noarch.rpm
pg_grammar_guard_17 0.4.1 el10.aarch64 pigsty 27.3 KiB pg_grammar_guard_17-0.4.1-1PGSTY.el10.noarch.rpm
postgresql-17-pg-grammar-guard 0.4.1 d12.x86_64 pigsty 21.4 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-17-pg-grammar-guard 0.4.1 d12.aarch64 pigsty 21.4 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-17-pg-grammar-guard 0.4.1 d13.x86_64 pigsty 21.4 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-17-pg-grammar-guard 0.4.1 d13.aarch64 pigsty 21.4 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u22.x86_64 pigsty 22.1 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u22.aarch64 pigsty 22.1 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u24.x86_64 pigsty 22.0 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u24.aarch64 pigsty 22.0 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u26.x86_64 pigsty 22.0 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
postgresql-17-pg-grammar-guard 0.4.1 u26.aarch64 pigsty 22.0 KiB postgresql-17-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
Package Version OS ORG SIZE File URL
pg_grammar_guard_16 0.4.1 el8.x86_64 pigsty 27.6 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_16 0.4.1 el8.aarch64 pigsty 27.6 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_16 0.4.1 el9.x86_64 pigsty 27.3 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_16 0.4.1 el9.aarch64 pigsty 27.2 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_16 0.4.1 el10.x86_64 pigsty 27.4 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el10.noarch.rpm
pg_grammar_guard_16 0.4.1 el10.aarch64 pigsty 27.3 KiB pg_grammar_guard_16-0.4.1-1PGSTY.el10.noarch.rpm
postgresql-16-pg-grammar-guard 0.4.1 d12.x86_64 pigsty 21.4 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-16-pg-grammar-guard 0.4.1 d12.aarch64 pigsty 21.4 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-16-pg-grammar-guard 0.4.1 d13.x86_64 pigsty 21.4 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-16-pg-grammar-guard 0.4.1 d13.aarch64 pigsty 21.4 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u22.x86_64 pigsty 22.1 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u22.aarch64 pigsty 22.1 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u24.x86_64 pigsty 22.0 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u24.aarch64 pigsty 22.0 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u26.x86_64 pigsty 22.0 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
postgresql-16-pg-grammar-guard 0.4.1 u26.aarch64 pigsty 22.0 KiB postgresql-16-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
Package Version OS ORG SIZE File URL
pg_grammar_guard_15 0.4.1 el8.x86_64 pigsty 27.6 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_15 0.4.1 el8.aarch64 pigsty 27.6 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_15 0.4.1 el9.x86_64 pigsty 27.2 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_15 0.4.1 el9.aarch64 pigsty 27.2 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_15 0.4.1 el10.x86_64 pigsty 27.4 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el10.noarch.rpm
pg_grammar_guard_15 0.4.1 el10.aarch64 pigsty 27.3 KiB pg_grammar_guard_15-0.4.1-1PGSTY.el10.noarch.rpm
postgresql-15-pg-grammar-guard 0.4.1 d12.x86_64 pigsty 21.4 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-15-pg-grammar-guard 0.4.1 d12.aarch64 pigsty 21.4 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-15-pg-grammar-guard 0.4.1 d13.x86_64 pigsty 21.4 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-15-pg-grammar-guard 0.4.1 d13.aarch64 pigsty 21.4 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u22.x86_64 pigsty 22.1 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u22.aarch64 pigsty 22.1 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u24.x86_64 pigsty 22.0 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u24.aarch64 pigsty 22.0 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u26.x86_64 pigsty 22.0 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
postgresql-15-pg-grammar-guard 0.4.1 u26.aarch64 pigsty 22.0 KiB postgresql-15-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
Package Version OS ORG SIZE File URL
pg_grammar_guard_14 0.4.1 el8.x86_64 pigsty 27.6 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_14 0.4.1 el8.aarch64 pigsty 27.6 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el8.noarch.rpm
pg_grammar_guard_14 0.4.1 el9.x86_64 pigsty 27.2 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_14 0.4.1 el9.aarch64 pigsty 27.2 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el9.noarch.rpm
pg_grammar_guard_14 0.4.1 el10.x86_64 pigsty 27.4 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el10.noarch.rpm
pg_grammar_guard_14 0.4.1 el10.aarch64 pigsty 27.3 KiB pg_grammar_guard_14-0.4.1-1PGSTY.el10.noarch.rpm
postgresql-14-pg-grammar-guard 0.4.1 d12.x86_64 pigsty 21.4 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-14-pg-grammar-guard 0.4.1 d12.aarch64 pigsty 21.4 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~bookworm_all.deb
postgresql-14-pg-grammar-guard 0.4.1 d13.x86_64 pigsty 21.4 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-14-pg-grammar-guard 0.4.1 d13.aarch64 pigsty 21.4 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~trixie_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u22.x86_64 pigsty 22.1 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u22.aarch64 pigsty 22.1 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~jammy_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u24.x86_64 pigsty 22.0 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u24.aarch64 pigsty 22.0 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~noble_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u26.x86_64 pigsty 22.0 KiB postgresql-14-pg-grammar-guard_0.4.1-1PGSTY~resolute_all.deb
postgresql-14-pg-grammar-guard 0.4.1 u26.aarch64 pigsty 22.0 KiB postgresql-14-pg-grammar-guard_0.4.1-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 via package name, for the active PG version

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
pig install pg_grammar_guard -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_grammar_guard CASCADE; -- requires pg_living_assertions

Usage

Sources:

pg_grammar_guard 0.4.8 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.9 or later.

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.