diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index db86262b4f06ec5b78f834eb10fbae45a1e77033..eca064f0cdef7ee6367b76a4da785e29a9cfdbc6 100644
*** a/src/backend/catalog/dependency.c
--- b/src/backend/catalog/dependency.c
*************** findDependentObjects(const ObjectAddress
*** 560,576 ****
  				 * another object, or is part of the extension that is the
  				 * other object.  We have three cases:
  				 *
! 				 * 1. At the outermost recursion level, disallow the DROP. (We
! 				 * just ereport here, rather than proceeding, since no other
! 				 * dependencies are likely to be interesting.)	However, if
! 				 * the owning object is listed in pendingObjects, just release
! 				 * the caller's lock and return; we'll eventually complete the
! 				 * DROP when we reach that entry in the pending list.
  				 */
  				if (stack == NULL)
  				{
  					char	   *otherObjDesc;
  
  					if (pendingObjects &&
  						object_address_present(&otherObject, pendingObjects))
  					{
--- 560,580 ----
  				 * another object, or is part of the extension that is the
  				 * other object.  We have three cases:
  				 *
! 				 * 1. At the outermost recursion level, we normally disallow
! 				 * the DROP.  (We just ereport here, rather than proceeding,
! 				 * since no other dependencies are likely to be interesting.)
! 				 * However, there are exceptions.
  				 */
  				if (stack == NULL)
  				{
  					char	   *otherObjDesc;
  
+ 					/*
+ 					 * Exception 1a: if the owning object is listed in
+ 					 * pendingObjects, just release the caller's lock and
+ 					 * return.  We'll eventually complete the DROP when we
+ 					 * reach that entry in the pending list.
+ 					 */
  					if (pendingObjects &&
  						object_address_present(&otherObject, pendingObjects))
  					{
*************** findDependentObjects(const ObjectAddress
*** 579,584 ****
--- 583,603 ----
  						ReleaseDeletionLock(object);
  						return;
  					}
+ 
+ 					/*
+ 					 * Exception 1b: if the owning object is the extension
+ 					 * currently being created/altered, it's okay to continue
+ 					 * with the deletion.  This allows dropping of an
+ 					 * extension's objects within the extension's scripts,
+ 					 * as well as corner cases such as dropping a transient
+ 					 * object created within such a script.
+ 					 */
+ 					if (creating_extension &&
+ 						otherObject.classId == ExtensionRelationId &&
+ 						otherObject.objectId == CurrentExtensionObject)
+ 						break;
+ 
+ 					/* No exception applies, so throw the error */
  					otherObjDesc = getObjectDescription(&otherObject);
  					ereport(ERROR,
  							(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
