pglinter
pglinter : PostgreSQL Linting and Analysis Extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5090 | pglinter | pglinter | 1.1.2 | ADMIN | PostgreSQL | Rust |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-dt- | No | Yes | No | Yes | no | yes |
| Relationships | |
|---|---|
| See Also | amcheck supautils |
manually upgraded PGRX from 0.16.1 to 0.17.0 by Vonng
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.2 | 18 17 16 15 14 | pglinter | - |
| RPM | PIGSTY | 1.1.2 | 18 17 16 15 14 | pglinter_$v | - |
| DEB | PIGSTY | 1.1.2 | 18 17 16 15 14 | postgresql-$v-pglinter | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
el8.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
el9.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
el9.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
el10.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
el10.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
d12.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
d12.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
d13.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
d13.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
u22.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
u22.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
u24.x86_64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
u24.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
u26.x86_64 | MISS | MISS | MISS | MISS | MISS |
u26.aarch64 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 | PIGSTY 1.1.2 |
Source
pig build pkg pglinter; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pglinter; # install via package name, for the active PG version
pig install pglinter -v 18; # install for PG 18
pig install pglinter -v 17; # install for PG 17
pig install pglinter -v 16; # install for PG 16
pig install pglinter -v 15; # install for PG 15
pig install pglinter -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pglinter;Usage
- Sources: README, how-to, examples, rules, 1.1.2 release
pglinter analyzes a PostgreSQL database for potential issues, performance problems, and best practice violations. Current user docs expose findings through pglinter.get_violations(), which returns enabled-rule violations as rows that can be filtered or joined to pg_identify_object().
Run Checks
SELECT * FROM pglinter.get_violations();
SELECT * FROM pglinter.get_violations() WHERE rule_code = 'B001';
SELECT
rule_code,
(pg_identify_object(classid, objid, objsubid)).type AS object_type,
(pg_identify_object(classid, objid, objsubid)).schema AS object_schema,
(pg_identify_object(classid, objid, objsubid)).name AS object_name,
(pg_identify_object(classid, objid, objsubid)).identity AS object_identity
FROM pglinter.get_violations();Rule Management
SELECT pglinter.show_rules(); -- Show all rules and their status
SELECT pglinter.explain_rule('B001'); -- Get rule details and suggested fixes
SELECT pglinter.enable_rule('B001'); -- Enable a specific rule
SELECT pglinter.disable_rule('B001'); -- Disable a specific rule
SELECT pglinter.is_rule_enabled('B001'); -- Check if a rule is enabled
SELECT pglinter.enable_all_rules();
SELECT pglinter.disable_all_rules();
SELECT pglinter.show_rule_queries('B001'); -- Inspect the rule query
SELECT pglinter.list_rules(); -- Return a formatted rule listRule Import And Export
SELECT pglinter.export_rules_to_yaml(); -- Export rules to YAML
SELECT pglinter.import_rules_from_yaml('yaml...'); -- Import rules from YAML
SELECT pglinter.export_rules_to_file('/path/to/rules.yaml');
SELECT pglinter.import_rules_from_file('/path/to/rules.yaml');
SELECT pglinter.export_rulemessages_to_yaml();
SELECT pglinter.import_rule_messages_from_yaml('yaml...');Rule Families
Base (B-series): B001 tables without PK, B002 redundant indexes, B003 missing FK indexes, B004 unused indexes, B005 uppercase names, B006 unused tables, B007 cross-schema FKs, B008 FK type mismatches, B009 shared trigger functions, B010 reserved keywords, B011 multiple owners per schema, B012 composite primary keys with more than four columns, B013 row-by-row trigger processing without a WHERE clause.
Cluster (C-series): C002 insecure pg_hba.conf entries, C003 MD5 password encryption.
Schema (S-series): S001 no default role grants, S002 env prefixes/suffixes, S003 unsecured public schema, S004 system role ownership, S005 multiple owners per schema.
Caveats
Pigsty package metadata is version 1.1.2 for PostgreSQL 14-18 and notes a local PGRX upgrade from 0.16.1 to 0.17.0. Upstream README compatibility text still says PostgreSQL 13-18 and PGRX 0.16.1.
The upstream 1.1.2 release adds B013. The main README remains partially stale compared with the docs and exported functions, so this stub uses get_violations() and omits older unconfirmed check()/check_rule() examples.