@@ -16447,54 +16447,6 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel)
1644716447 MemoryContextDelete(cxt);
1644816448}
1644916449
16450- /*
16451- * isPartitionTrigger
16452- * Subroutine for CloneRowTriggersToPartition: determine whether
16453- * the given trigger has been cloned from another one.
16454- *
16455- * We use pg_depend as a proxy for this, since we don't have any direct
16456- * evidence. This is an ugly hack to cope with a catalog deficiency.
16457- * Keep away from children. Do not stare with naked eyes. Do not propagate.
16458- */
16459- static bool
16460- isPartitionTrigger(Oid trigger_oid)
16461- {
16462- Relation pg_depend;
16463- ScanKeyData key[2];
16464- SysScanDesc scan;
16465- HeapTuple tup;
16466- bool found = false;
16467-
16468- pg_depend = table_open(DependRelationId, AccessShareLock);
16469-
16470- ScanKeyInit(&key[0], Anum_pg_depend_classid,
16471- BTEqualStrategyNumber,
16472- F_OIDEQ,
16473- ObjectIdGetDatum(TriggerRelationId));
16474- ScanKeyInit(&key[1], Anum_pg_depend_objid,
16475- BTEqualStrategyNumber,
16476- F_OIDEQ,
16477- ObjectIdGetDatum(trigger_oid));
16478-
16479- scan = systable_beginscan(pg_depend, DependDependerIndexId,
16480- true, NULL, 2, key);
16481- while ((tup = systable_getnext(scan)) != NULL)
16482- {
16483- Form_pg_depend dep = (Form_pg_depend) GETSTRUCT(tup);
16484-
16485- if (dep->refclassid == TriggerRelationId)
16486- {
16487- found = true;
16488- break;
16489- }
16490- }
16491-
16492- systable_endscan(scan);
16493- table_close(pg_depend, AccessShareLock);
16494-
16495- return found;
16496- }
16497-
1649816450/*
1649916451 * CloneRowTriggersToPartition
1650016452 * subroutine for ATExecAttachPartition/DefineRelation to create row
@@ -16537,19 +16489,18 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
1653716489
1653816490 /*
1653916491 * Internal triggers require careful examination. Ideally, we don't
16540- * clone them.
16541- *
16542- * However, if our parent is a partitioned relation, there might be
16543- * internal triggers that need cloning. In that case, we must skip
16544- * clone it if the trigger on parent depends on another trigger.
16492+ * clone them. However, if our parent is itself a partition, there
16493+ * might be internal triggers that must not be skipped; for example,
16494+ * triggers on our parent that are in turn clones from its parent (our
16495+ * grandparent) are marked internal, yet they are to be cloned.
1654516496 *
1654616497 * Note we dare not verify that the other trigger belongs to an
1654716498 * ancestor relation of our parent, because that creates deadlock
1654816499 * opportunities.
1654916500 */
1655016501 if (trigForm->tgisinternal &&
1655116502 (!parent->rd_rel->relispartition ||
16552- !isPartitionTrigger (trigForm->oid )))
16503+ !OidIsValid (trigForm->tgparentid )))
1655316504 continue;
1655416505
1655516506 /*
0 commit comments