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

Commit e1e1b52

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 dbd35a9 commit e1e1b52

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/catalog/pg_type.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ TypeCreate(Oid newTypeOid,
484484
*
485485
* If rebuild is true, we remove existing dependencies and rebuild them
486486
* from scratch. This is needed for ALTER TYPE, and also when replacing
487-
* a shell type.
487+
* a shell type. We don't remove an existing extension dependency, though.
488+
* (That means an extension can't absorb a shell type created in another
489+
* extension, nor ALTER a type created by another extension. Also, if it
490+
* replaces a free-standing shell type or ALTERs a free-standing type,
491+
* that type will become a member of the extension.)
488492
*/
489493
void
490494
GenerateTypeDependencies(Oid typeNamespace,
@@ -509,6 +513,7 @@ GenerateTypeDependencies(Oid typeNamespace,
509513
ObjectAddress myself,
510514
referenced;
511515

516+
/* If rebuild, first flush old dependencies, except extension deps */
512517
if (rebuild)
513518
{
514519
deleteDependencyRecordsFor(TypeRelationId, typeObjectId, true);
@@ -520,7 +525,7 @@ GenerateTypeDependencies(Oid typeNamespace,
520525
myself.objectSubId = 0;
521526

522527
/*
523-
* Make dependency on namespace and shared dependency on owner.
528+
* Make dependencies on namespace, owner, extension.
524529
*
525530
* For a relation rowtype (that's not a composite type), we should skip
526531
* these because we'll depend on them indirectly through the pg_class
@@ -536,10 +541,9 @@ GenerateTypeDependencies(Oid typeNamespace,
536541
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
537542

538543
recordDependencyOnOwner(TypeRelationId, typeObjectId, owner);
539-
}
540544

541-
/* dependency on extension */
542-
recordDependencyOnCurrentExtension(&myself, rebuild);
545+
recordDependencyOnCurrentExtension(&myself, rebuild);
546+
}
543547

544548
/* Normal dependencies on the I/O functions */
545549
if (OidIsValid(inputProcedure))

0 commit comments

Comments
 (0)