Skip to content

feat: add pgfence-inspired safety lint rules#703

Draft
psteinroe wants to merge 3 commits intomainfrom
feat/pgfence-rules
Draft

feat: add pgfence-inspired safety lint rules#703
psteinroe wants to merge 3 commits intomainfrom
feat/pgfence-rules

Conversation

@psteinroe
Copy link
Collaborator

  • Add 18 new safety lint rules ported from pgfence (ban truncate, vacuum full, drop schema, triggers, partitions, reindex, matview refresh, destructive DML without WHERE, exclusion constraints, enum add value, wide lock window, NOT VALID + VALIDATE in same tx)
  • Extend TransactionState to track statement_timeout, idle_in_transaction_session_timeout, NOT VALID constraints, and ACCESS EXCLUSIVE table sets
  • Improve ChangingColumnType to allow safe type widenings (text, varchar without length, numeric without precision)
  • Extend PreferRobustStmts to cover CREATE TABLE IF NOT EXISTS and DROP TABLE IF EXISTS

@psteinroe psteinroe marked this pull request as draft March 1, 2026 17:19
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Handle BEGIN/COMMIT/ROLLBACK in TransactionState to reset accumulated
  state across transaction boundaries (prevents false positives)
- Table-qualify NOT VALID constraint tracking to avoid false positives
  when different tables share constraint names
- Filter AT_ValidateConstraint from ACCESS EXCLUSIVE lock tracking
  (it takes SHARE UPDATE EXCLUSIVE)
- Remove non-concurrent CREATE INDEX from ACCESS EXCLUSIVE tracking
  (it takes SHARE lock, not ACCESS EXCLUSIVE)
- Expand is_dangerous_lock_stmt to cover DropStmt, TruncateStmt,
  VacuumStmt, ReindexStmt, RenameStmt, RefreshMatViewStmt
- Move is_dangerous_lock_stmt to shared TransactionState method
  (was duplicated in require_statement_timeout and
  require_idle_in_transaction_timeout)
- Change ban_truncate severity from Warning to Error (irreversible
  data loss)
- Fix ban_alter_enum_add_value messaging: remove incorrect ACCESS
  EXCLUSIVE claim, note PG12+ instant behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant