pglinter

PostgreSQL Linting and Analysis Extension

Overview

PackageVersionCategoryLicenseLanguage
pglinter1.1.2ADMINPostgreSQLRust
IDExtensionBinLibLoadCreateTrustRelocSchema
5090pglinterNoYesNoYesYesNo-
Relatedamcheck supautils

manually upgraded PGRX from 0.16.1 to 0.17.0 by Vonng

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.1.21817161514pglinter-
RPMPIGSTY1.1.21817161514pglinter_$v-
DEBPIGSTY1.1.21817161514postgresql-$v-pglinter-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
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
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
u24.aarch64
PIGSTY 1.1.2
PIGSTY 1.1.2
PIGSTY 1.1.2
PIGSTY 1.1.2
PIGSTY 1.1.2
u26.x86_64PIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISS
u26.aarch64

Build

You can build the RPM / DEB packages for pglinter using pig build:

pig build pkg pglinter         # build RPM / DEB packages

Install

You can install pglinter directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install pglinter;          # Install for current active PG version
pig ext install -y pglinter -v 18  # PG 18
pig ext install -y pglinter -v 17  # PG 17
pig ext install -y pglinter -v 16  # PG 16
pig ext install -y pglinter -v 15  # PG 15
pig ext install -y pglinter -v 14  # PG 14
dnf install -y pglinter_18       # PG 18
dnf install -y pglinter_17       # PG 17
dnf install -y pglinter_16       # PG 16
dnf install -y pglinter_15       # PG 15
dnf install -y pglinter_14       # PG 14
apt install -y postgresql-18-pglinter   # PG 18
apt install -y postgresql-17-pglinter   # PG 17
apt install -y postgresql-16-pglinter   # PG 16
apt install -y postgresql-15-pglinter   # PG 15
apt install -y postgresql-14-pglinter   # PG 14

Create Extension:

CREATE EXTENSION pglinter;

Usage

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 list

Rule 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.


Last Modified 2026-05-18: routine extension update (cfff783)