]> granicus.if.org Git - postgresql/commitdiff
Don't mark auto-generated types as extension members.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Oct 2011 22:40:09 +0000 (18:40 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Oct 2011 22:40:28 +0000 (18:40 -0400)
Relation rowtypes and automatically-generated array types do not need to
have their own extension membership dependency entries.  If we create such
then it becomes more difficult to remove items from an extension, and it's
also harder for an extension upgrade script to make sure it duplicates the
dependencies created by the extension's regular installation script.

I changed the code in such a way that this happened in commit
988cccc620dd8c16d77f88ede167b22056176324, I think because of worries about
the shell-type-replacement case; but that cure was worse than the disease.
It would only matter if one extension created a shell type that was
replaced with an auto-generated type in another extension, which seems
pretty far-fetched.  Better to make this work unsurprisingly in normal
cases.

Report and patch by Robert Haas, comment adjustments by me.

src/backend/catalog/pg_type.c

index c31f6e9582b69c2e32c8dfc1cfb8e3acc4719a2f..95b17d764edd794b484a35c4867211ff1360f1d2 100644 (file)
@@ -484,7 +484,11 @@ TypeCreate(Oid newTypeOid,
  *
  * If rebuild is true, we remove existing dependencies and rebuild them
  * from scratch.  This is needed for ALTER TYPE, and also when replacing
- * a shell type.
+ * a shell type.  We don't remove an existing extension dependency, though.
+ * (That means an extension can't absorb a shell type created in another
+ * extension, nor ALTER a type created by another extension.  Also, if it
+ * replaces a free-standing shell type or ALTERs a free-standing type,
+ * that type will become a member of the extension.)
  */
 void
 GenerateTypeDependencies(Oid typeNamespace,
@@ -509,6 +513,7 @@ GenerateTypeDependencies(Oid typeNamespace,
        ObjectAddress myself,
                                referenced;
 
+       /* If rebuild, first flush old dependencies, except extension deps */
        if (rebuild)
        {
                deleteDependencyRecordsFor(TypeRelationId, typeObjectId, true);
@@ -520,7 +525,7 @@ GenerateTypeDependencies(Oid typeNamespace,
        myself.objectSubId = 0;
 
        /*
-        * Make dependency on namespace and shared dependency on owner.
+        * Make dependencies on namespace, owner, extension.
         *
         * For a relation rowtype (that's not a composite type), we should skip
         * these because we'll depend on them indirectly through the pg_class
@@ -536,10 +541,9 @@ GenerateTypeDependencies(Oid typeNamespace,
                recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
 
                recordDependencyOnOwner(TypeRelationId, typeObjectId, owner);
-       }
 
-       /* dependency on extension */
-       recordDependencyOnCurrentExtension(&myself, rebuild);
+               recordDependencyOnCurrentExtension(&myself, rebuild);
+       }
 
        /* Normal dependencies on the I/O functions */
        if (OidIsValid(inputProcedure))