Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables
Date: 2020-04-20 23:04:06
Message-ID: 20200420230406.GA27302@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> + deleteDependencyRecordsFor(TriggerRelationId,
> + pg_trigger->oid,
> + false);
> + deleteDependencyRecordsFor(RelationRelationId,
> + pg_trigger->oid,
> + false);
> +
> + CommandCounterIncrement();
> + ObjectAddressSet(object, TriggerRelationId, pg_trigger->oid);
> + }
> +
> + systable_endscan(scan);
> + table_close(tgrel, RowExclusiveLock);
> + }

Two small issues here. First, your second call to
deleteDependencyRecordsFor did nothing, because your first call deleted
all the dependency records. I changed that to two
deleteDependencyRecordsForClass() calls, that actually do what you

The other is that instead of deleting each trigger, we can accumulate
them to delete with a single performMultipleDeletions call; this also
means we get to do CommandCounterIncrement just once.

v6 fixes those things and AFAICS is ready to push.

I haven't reviewed your 0002 carefully, but (as inventor of the "TABLE
t" marker for FK constraints) I agree with Amit that we should imitate
that instead of coming up with a new way to show it.

Álvaro Herrera
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v6-0001-Fix-detaching-tables-with-inherited-row-triggers.patch text/x-diff 9.1 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2020-04-20 23:44:45 Fix for pg_statio_all_tables
Previous Message Alvaro Herrera 2020-04-20 22:14:33 Re: Poll: are people okay with function/operator table redesign?