Skip to content

Partition-clone child triggers (tgparentid != 0) are dumped even when child tables are ignored; qualified [triggers] patterns do not match #472

@thomas-huerlimann

Description

@thomas-huerlimann

Summary

Two related problems when a partitioned parent has a FOR EACH ROW trigger (which PostgreSQL automatically clones onto every partition child, with pg_trigger.tgparentid set):

  1. dump emits the cloned child triggers as standalone CREATE OR REPLACE TRIGGER ... ON <child> statements even when the child tables are excluded via .pgschemaignore. The resulting desired-state file then fails pgschema's own plan with ERROR: relation "<child>" does not exist, because the ignored child tables are absent from the temp schema. This is the trigger analog of Skipping privileges for specific functions with .pgschemaignore #392/fix: skip privileges for ignored objects in .pgschemaignore (#392) #393 (privileges of ignored objects) and skip constraints for foreign keys referencing ignored tables (.pgschemaignore) #409/fix: skip internal per-partition FK constraints in dump (#409) #460 (internal per-partition FK constraints).
  2. Qualified patterns in the [triggers] section ("<child_table>.<trigger_name>") do not match; only the unqualified trigger name matches. Since the cloned child triggers share the parent trigger's name, the only working ignore ("<trigger_name>") also unmanages the parent trigger.

Repro (pgschema 1.11.1, PostgreSQL 17)

CREATE TABLE ledger (
    id uuid NOT NULL,
    amount bigint NOT NULL,
    ts timestamptz NOT NULL,
    PRIMARY KEY (ts, id)
) PARTITION BY RANGE (ts);

CREATE TABLE ledger_2026_06 PARTITION OF ledger
    FOR VALUES FROM ('2026-06-01') TO ('2026-07-01');

CREATE FUNCTION tg_noop() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RETURN NEW; END $$;

CREATE TRIGGER trg_rollup AFTER INSERT ON ledger
    FOR EACH ROW EXECUTE FUNCTION tg_noop();

.pgschemaignore:

[tables]
patterns = ["ledger_2*"]
  • pgschema dump still contains CREATE OR REPLACE TRIGGER trg_rollup ... ON ledger_2026_06 -> plan --file <dump> fails with relation "ledger_2026_06" does not exist.
  • Adding [triggers] patterns = ["ledger_2*.trg_rollup"] does not filter it; patterns = ["trg_rollup"] does, but also removes the parent trigger from management.

Expected

  • Triggers with tgparentid != 0 (partition clones) are skipped in dump unconditionally - they are created automatically by PostgreSQL when the child is attached, mirroring the fix: skip internal per-partition FK constraints in dump (#409) #460 treatment of internal per-partition FK constraints.
  • Alternatively/additionally: [triggers] patterns support a table.trigger qualified form.

Observed on both 1.10.0 and 1.11.1 (Docker images), server PostgreSQL 17.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions