Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7b96519

Browse files
committed
Don't mark auto-generated types as extension members.
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 988cccc, 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.
1 parent e0b268f commit 7b96519

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/catalog/pg_type.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,11 @@ TypeCreate(Oid newTypeOid,
480480
*
481481
* If rebuild is true, we remove existing dependencies and rebuild them
482482
* from scratch. This is needed for ALTER TYPE, and also when replacing
483-
* a shell type.
483+
* a shell type. We don't remove an existing extension dependency, though.
484+
* (That means an extension can't absorb a shell type created in another
485+
* extension, nor ALTER a type created by another extension. Also, if it
486+
* replaces a free-standing shell type or ALTERs a free-standing type,
487+
* that type will become a member of the extension.)
484488
*/
485489
void
486490
GenerateTypeDependencies(Oid typeNamespace,
@@ -505,6 +509,7 @@ GenerateTypeDependencies(Oid typeNamespace,
505509
ObjectAddress myself,
506510
referenced;
507511

512+
/* If rebuild, first flush old dependencies, except extension deps */
508513
if (rebuild)
509514
{
510515
deleteDependencyRecordsFor(TypeRelationId, typeObjectId, true);
@@ -516,7 +521,7 @@ GenerateTypeDependencies(Oid typeNamespace,
516521
myself.objectSubId = 0;
517522

518523
/*
519-
* Make dependency on namespace and shared dependency on owner.
524+
* Make dependencies on namespace, owner, extension.
520525
*
521526
* For a relation rowtype (that's not a composite type), we should skip
522527
* these because we'll depend on them indirectly through the pg_class
@@ -532,10 +537,9 @@ GenerateTypeDependencies(Oid typeNamespace,
532537
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
533538

534539
recordDependencyOnOwner(TypeRelationId, typeObjectId, owner);
535-
}
536540

537-
/* dependency on extension */
538-
recordDependencyOnCurrentExtension(&myself, rebuild);
541+
recordDependencyOnCurrentExtension(&myself, rebuild);
542+
}
539543

540544
/* Normal dependencies on the I/O functions */
541545
if (OidIsValid(inputProcedure))

0 commit comments

Comments
 (0)