@@ -816,7 +816,7 @@ RemoveRelations(DropStmt *drop)
816816 add_exact_object_address (& obj , objects );
817817 }
818818
819- performMultipleDeletions (objects , drop -> behavior );
819+ performMultipleDeletions (objects , drop -> behavior , 0 );
820820
821821 free_object_addresses (objects );
822822}
@@ -4803,8 +4803,13 @@ ATExecColumnDefault(Relation rel, const char *colName,
48034803 * Remove any old default for the column. We use RESTRICT here for
48044804 * safety, but at present we do not expect anything to depend on the
48054805 * default.
4806+ *
4807+ * We treat removing the existing default as an internal operation when
4808+ * it is preparatory to adding a new default, but as a user-initiated
4809+ * operation when the user asked for a drop.
48064810 */
4807- RemoveAttrDefault (RelationGetRelid (rel ), attnum , DROP_RESTRICT , false);
4811+ RemoveAttrDefault (RelationGetRelid (rel ), attnum , DROP_RESTRICT , false,
4812+ newDefault == NULL ? false : true);
48084813
48094814 if (newDefault )
48104815 {
@@ -5217,7 +5222,7 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
52175222 object .objectId = RelationGetRelid (rel );
52185223 object .objectSubId = attnum ;
52195224
5220- performDeletion (& object , behavior );
5225+ performDeletion (& object , behavior , 0 );
52215226
52225227 /*
52235228 * If we dropped the OID column, must adjust pg_class.relhasoids and tell
@@ -6731,7 +6736,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
67316736 conobj .objectId = HeapTupleGetOid (tuple );
67326737 conobj .objectSubId = 0 ;
67336738
6734- performDeletion (& conobj , behavior );
6739+ performDeletion (& conobj , behavior , 0 );
67356740
67366741 found = true;
67376742
@@ -7453,7 +7458,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
74537458 * We use RESTRICT here for safety, but at present we do not expect
74547459 * anything to depend on the default.
74557460 */
7456- RemoveAttrDefault (RelationGetRelid (rel ), attnum , DROP_RESTRICT , true);
7461+ RemoveAttrDefault (RelationGetRelid (rel ), attnum , DROP_RESTRICT , true,
7462+ true);
74577463
74587464 StoreAttrDefault (rel , attnum , defaultexpr );
74597465 }
@@ -7598,15 +7604,15 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode)
75987604 obj .classId = ConstraintRelationId ;
75997605 obj .objectId = lfirst_oid (oid_item );
76007606 obj .objectSubId = 0 ;
7601- performDeletion (& obj , DROP_RESTRICT );
7607+ performDeletion (& obj , DROP_RESTRICT , PERFORM_DELETION_INTERNAL );
76027608 }
76037609
76047610 foreach (oid_item , tab -> changedIndexOids )
76057611 {
76067612 obj .classId = RelationRelationId ;
76077613 obj .objectId = lfirst_oid (oid_item );
76087614 obj .objectSubId = 0 ;
7609- performDeletion (& obj , DROP_RESTRICT );
7615+ performDeletion (& obj , DROP_RESTRICT , PERFORM_DELETION_INTERNAL );
76107616 }
76117617
76127618 /*
@@ -9764,7 +9770,14 @@ PreCommit_on_commit_actions(void)
97649770 object .classId = RelationRelationId ;
97659771 object .objectId = oc -> relid ;
97669772 object .objectSubId = 0 ;
9767- performDeletion (& object , DROP_CASCADE );
9773+
9774+ /*
9775+ * Since this is an automatic drop, rather than one
9776+ * directly initiated by the user, we pass the
9777+ * PERFORM_DELETION_INTERNAL flag.
9778+ */
9779+ performDeletion (& object ,
9780+ DROP_CASCADE , PERFORM_DELETION_INTERNAL );
97689781
97699782 /*
97709783 * Note that table deletion will call
0 commit comments