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

Commit2cbb62d

Browse files
committed
Fix test about ignoring extension dependencies during extension scripts.
Commit08dd23c introduced an exception to the rule that extension memberobjects can only be dropped as part of dropping the whole extension,intending to allow such drops while running the extension's own creation orupdate scripts. However, the exception was only applied at the outermostrecursion level, because it was modeled on a pre-existing check to ignoredependencies on objects listed in pendingObjects. Bug #14434 from PhilippeBeaudoin shows that this is inadequate: in some cases we can reach anextension member object by recursion from another one. (The bug concernsthe serial-sequence case; I'm not sure if there are other cases, but theremight well be.)To fix, revert08dd23c's changes to findDependentObjects() and insteadapply the creating_extension exception regardless of stack level.Having seen this example, I'm a bit suspicious that the pendingObjectslogic is also wrong and such cases should likewise be allowed at anyrecursion level. However, changing that would interact in subtle wayswith the recursion logic (at least it would need to be moved to after therecursing-from check). Given that the code's been like that a long time,I'll refrain from touching it without a clear example showing it's wrong.Back-patch to all active branches. In HEAD and 9.6, where suitabletest infrastructure exists, add a regression test case based on thebug report.Report: <20161125151448.6529.33039@wrigleys.postgresql.org>Discussion: <13224.1480177514@sss.pgh.pa.us>
1 parent05bef7b commit2cbb62d

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -574,29 +574,43 @@ findDependentObjects(const ObjectAddress *object,
574574
caseDEPENDENCY_AUTO:
575575
/* no problem */
576576
break;
577-
caseDEPENDENCY_INTERNAL:
577+
578578
caseDEPENDENCY_EXTENSION:
579579

580+
/*
581+
* If the other object is the extension currently being
582+
* created/altered, ignore this dependency and continue with
583+
* the deletion. This allows dropping of an extension's
584+
* objects within the extension's scripts, as well as corner
585+
* cases such as dropping a transient object created within
586+
* such a script.
587+
*/
588+
if (creating_extension&&
589+
otherObject.classId==ExtensionRelationId&&
590+
otherObject.objectId==CurrentExtensionObject)
591+
break;
592+
593+
/* Otherwise, treat this like an internal dependency */
594+
/* FALL THRU */
595+
596+
caseDEPENDENCY_INTERNAL:
597+
580598
/*
581599
* This object is part of the internal implementation of
582600
* another object, or is part of the extension that is the
583601
* other object. We have three cases:
584602
*
585-
* 1. At the outermost recursion level, we normally disallow
586-
* the DROP. (We just ereport here, rather than proceeding,
587-
* since no other dependencies are likely to be interesting.)
588-
* However, there are exceptions.
603+
* 1. At the outermost recursion level, disallow the DROP. (We
604+
* just ereport here, rather than proceeding, since no other
605+
* dependencies are likely to be interesting.)However, if
606+
* the owning object is listed in pendingObjects, just release
607+
* the caller's lock and return; we'll eventually complete the
608+
* DROP when we reach that entry in the pending list.
589609
*/
590610
if (stack==NULL)
591611
{
592612
char*otherObjDesc;
593613

594-
/*
595-
* Exception 1a: if the owning object is listed in
596-
* pendingObjects, just release the caller's lock and
597-
* return. We'll eventually complete the DROP when we
598-
* reach that entry in the pending list.
599-
*/
600614
if (pendingObjects&&
601615
object_address_present(&otherObject,pendingObjects))
602616
{
@@ -605,21 +619,6 @@ findDependentObjects(const ObjectAddress *object,
605619
ReleaseDeletionLock(object);
606620
return;
607621
}
608-
609-
/*
610-
* Exception 1b: if the owning object is the extension
611-
* currently being created/altered, it's okay to continue
612-
* with the deletion. This allows dropping of an
613-
* extension's objects within the extension's scripts, as
614-
* well as corner cases such as dropping a transient
615-
* object created within such a script.
616-
*/
617-
if (creating_extension&&
618-
otherObject.classId==ExtensionRelationId&&
619-
otherObject.objectId==CurrentExtensionObject)
620-
break;
621-
622-
/* No exception applies, so throw the error */
623622
otherObjDesc=getObjectDescription(&otherObject);
624623
ereport(ERROR,
625624
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp