I wrote: > I propose that we handle this case by adding a new DEPFLAG_IS_SUBOBJECT > flag to the column object's flags, denoting that we know the whole table > will be dropped later. The only effect of this flag is to suppress > reporting of the column object in reportDependentObjects.
Here's a proposed patch for that bit. As expected, it seems to eliminate the variation in number-of-cascaded-drops-reported under ignore_system_indexes. I do not see any regression outputs change otherwise. regards, tom lane
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index 3529084..6b8c735 100644 *** a/src/backend/catalog/dependency.c --- b/src/backend/catalog/dependency.c *************** typedef struct *** 102,107 **** --- 102,108 ---- #define DEPFLAG_INTERNAL 0x0008 /* reached via internal dependency */ #define DEPFLAG_EXTENSION 0x0010 /* reached via extension dependency */ #define DEPFLAG_REVERSE 0x0020 /* reverse internal/extension link */ + #define DEPFLAG_SUBOBJECT 0x0040 /* subobject of another deletable object */ /* expansible list of ObjectAddresses */ *************** reportDependentObjects(const ObjectAddre *** 886,891 **** --- 887,896 ---- if (extra->flags & DEPFLAG_ORIGINAL) continue; + /* Also ignore sub-objects; we'll report the whole object elsewhere */ + if (extra->flags & DEPFLAG_SUBOBJECT) + continue; + objDesc = getObjectDescription(obj); /* *************** object_address_present_add_flags(const O *** 2320,2332 **** * DROP COLUMN action even though we know we're gonna delete * the table later. * * Because there could be other subobjects of this object in * the array, this case means we always have to loop through * the whole array; we cannot exit early on a match. */ ObjectAddressExtra *thisextra = addrs->extras + i; ! thisextra->flags |= flags; } } } --- 2325,2343 ---- * DROP COLUMN action even though we know we're gonna delete * the table later. * + * What we can do, though, is mark this as a subobject so that + * we don't report it separately, which is confusing because + * it's unpredictable whether it happens or not. But do so + * only if flags != 0 (flags == 0 is a read-only probe). + * * Because there could be other subobjects of this object in * the array, this case means we always have to loop through * the whole array; we cannot exit early on a match. */ ObjectAddressExtra *thisextra = addrs->extras + i; ! if (flags) ! thisextra->flags |= (flags | DEPFLAG_SUBOBJECT); } } } *************** stack_address_present_add_flags(const Ob *** 2374,2380 **** * object_address_present_add_flags(), we should propagate * flags for the whole object to each of its subobjects. */ ! stackptr->flags |= flags; } } } --- 2385,2392 ---- * object_address_present_add_flags(), we should propagate * flags for the whole object to each of its subobjects. */ ! if (flags) ! stackptr->flags |= (flags | DEPFLAG_SUBOBJECT); } } }