diff options
author | Michael Paquier <michael@paquier.xyz> | 2020-07-01 11:12:33 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2020-07-01 11:12:33 +0900 |
commit | 684b4f29b729e5b135d256802d6e712222b9551f (patch) | |
tree | 61e9479c1a8c783dfd20b376b0864e2c975f0ce4 | |
parent | c4342c932abb6792f6c7d8528b6224ca4d5e1a84 (diff) | |
download | postgresql-684b4f29b729e5b135d256802d6e712222b9551f.tar.gz postgresql-684b4f29b729e5b135d256802d6e712222b9551f.zip |
Refactor creation of normal dependency records when creating extension
When creating an extension, the same type of dependency is used when
registering a dependency to a schema and required extensions. This
improves the code so as those dependencies are not recorded one-by-one,
but grouped together. Note that this has as side effect to remove
duplicate dependency entries, even if it should not happen in practice
as extensions listed as required in a control file should be listed only
once.
Extracted from a larger patch by the same author.
Author: Daniel Dustafsson
Discussion: https://postgr.es/m/20200629065535.GA183079@paquier.xyz
-rw-r--r-- | src/backend/commands/extension.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 472e69fdaf9..3b69ab7ed5c 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -1783,6 +1783,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner, HeapTuple tuple; ObjectAddress myself; ObjectAddress nsp; + ObjectAddresses *refobjs; ListCell *lc; /* @@ -1825,27 +1826,26 @@ InsertExtensionTuple(const char *extName, Oid extOwner, */ recordDependencyOnOwner(ExtensionRelationId, extensionOid, extOwner); - myself.classId = ExtensionRelationId; - myself.objectId = extensionOid; - myself.objectSubId = 0; + refobjs = new_object_addresses(); - nsp.classId = NamespaceRelationId; - nsp.objectId = schemaOid; - nsp.objectSubId = 0; + ObjectAddressSet(myself, ExtensionRelationId, extensionOid); - recordDependencyOn(&myself, &nsp, DEPENDENCY_NORMAL); + ObjectAddressSet(nsp, NamespaceRelationId, schemaOid); + add_exact_object_address(&nsp, refobjs); foreach(lc, requiredExtensions) { Oid reqext = lfirst_oid(lc); ObjectAddress otherext; - otherext.classId = ExtensionRelationId; - otherext.objectId = reqext; - otherext.objectSubId = 0; - - recordDependencyOn(&myself, &otherext, DEPENDENCY_NORMAL); + ObjectAddressSet(otherext, ExtensionRelationId, reqext); + add_exact_object_address(&otherext, refobjs); } + + /* Record all of them (this includes duplicate elimination) */ + record_object_address_dependencies(&myself, refobjs, DEPENDENCY_NORMAL); + free_object_addresses(refobjs); + /* Post creation hook for new extension */ InvokeObjectPostCreateHook(ExtensionRelationId, extensionOid, 0); |