@@ -16447,54 +16447,6 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel)
16447
16447
MemoryContextDelete(cxt);
16448
16448
}
16449
16449
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
-
16498
16450
/*
16499
16451
* CloneRowTriggersToPartition
16500
16452
* subroutine for ATExecAttachPartition/DefineRelation to create row
@@ -16537,19 +16489,18 @@ CloneRowTriggersToPartition(Relation parent, Relation partition)
16537
16489
16538
16490
/*
16539
16491
* 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.
16545
16496
*
16546
16497
* Note we dare not verify that the other trigger belongs to an
16547
16498
* ancestor relation of our parent, because that creates deadlock
16548
16499
* opportunities.
16549
16500
*/
16550
16501
if (trigForm->tgisinternal &&
16551
16502
(!parent->rd_rel->relispartition ||
16552
- !isPartitionTrigger (trigForm->oid )))
16503
+ !OidIsValid (trigForm->tgparentid )))
16553
16504
continue;
16554
16505
16555
16506
/*
0 commit comments