From: Faithfinder (@Faithfinder) <noreply+Faithfinder@github.com>
To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>
Subject: [pgpartman/pg_partman] issue #860: Feature: p_skip_on_error parameter for run_maintenance_proc()
Date: Thu, 23 Apr 2026 16:50:47 +0000
Message-ID: <gh-pgpartman-pg_partman-860@github.com> (raw)
# Problem
If run_maintenance() raises an unhandled exception for any table, the exception propagates out of the EXECUTE in the loop and aborts the entire procedure. All subsequent tables in the iteration are silently skipped.
A single misconfigured table causes all other partition sets to miss their maintenance window.
# Proposed change
Add p_skip_on_error boolean DEFAULT false to run_maintenance_proc(). When true, wrap each loop iteration in an exception block, emit a WARNING with the table name and error, and continue:
```sql
BEGIN
EXECUTE v_sql;
COMMIT;
EXCEPTION WHEN OTHERS THEN
ROLLBACK;
RAISE WARNING 'run_maintenance_proc: skipping % due to: % (%)',
v_row.parent_table, SQLERRM, SQLSTATE;
END;
```