Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9194c42

Browse files
committed
Avoid sometimes printing both tables and their columns in DROP CASCADE.
A cascaded drop might find independent reasons to drop both a tableand some column of the table (for instance, a schema drop might includedropping a data type used in some table in the schema). Depending onthe order of visitation of pg_depend entries, we might report thetable column and the whole table as separate objects-to-be-dropped,or we might only report the table. This is confusing and leads tounstable regression test output, so fix it to report only the tableregardless of visitation order.Per gripe from Peter Geoghegan. This is just cosmetic from a user'sstandpoint, and we haven't actually seen regression test problems inpractice (yet), so I'll refrain from back-patching.Discussion:https://postgr.es/m/15908.1547762076@sss.pgh.pa.us
1 parentf04ad77 commit9194c42

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef struct
102102
#defineDEPFLAG_INTERNAL0x0008/* reached via internal dependency */
103103
#defineDEPFLAG_EXTENSION0x0010/* reached via extension dependency */
104104
#defineDEPFLAG_REVERSE0x0020/* reverse internal/extension link */
105+
#defineDEPFLAG_SUBOBJECT0x0040/* subobject of another deletable object */
105106

106107

107108
/* expansible list of ObjectAddresses */
@@ -886,6 +887,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
886887
if (extra->flags&DEPFLAG_ORIGINAL)
887888
continue;
888889

890+
/* Also ignore sub-objects; we'll report the whole object elsewhere */
891+
if (extra->flags&DEPFLAG_SUBOBJECT)
892+
continue;
893+
889894
objDesc=getObjectDescription(obj);
890895

891896
/*
@@ -2320,13 +2325,19 @@ object_address_present_add_flags(const ObjectAddress *object,
23202325
* DROP COLUMN action even though we know we're gonna delete
23212326
* the table later.
23222327
*
2328+
* What we can do, though, is mark this as a subobject so that
2329+
* we don't report it separately, which is confusing because
2330+
* it's unpredictable whether it happens or not. But do so
2331+
* only if flags != 0 (flags == 0 is a read-only probe).
2332+
*
23232333
* Because there could be other subobjects of this object in
23242334
* the array, this case means we always have to loop through
23252335
* the whole array; we cannot exit early on a match.
23262336
*/
23272337
ObjectAddressExtra*thisextra=addrs->extras+i;
23282338

2329-
thisextra->flags |=flags;
2339+
if (flags)
2340+
thisextra->flags |= (flags |DEPFLAG_SUBOBJECT);
23302341
}
23312342
}
23322343
}
@@ -2374,7 +2385,8 @@ stack_address_present_add_flags(const ObjectAddress *object,
23742385
* object_address_present_add_flags(), we should propagate
23752386
* flags for the whole object to each of its subobjects.
23762387
*/
2377-
stackptr->flags |=flags;
2388+
if (flags)
2389+
stackptr->flags |= (flags |DEPFLAG_SUBOBJECT);
23782390
}
23792391
}
23802392
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp