Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 684b4f2

Browse files
committedJul 1, 2020
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
1 parent c4342c9 commit 684b4f2

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed
 

‎src/backend/commands/extension.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
17831783
HeapTuple tuple;
17841784
ObjectAddress myself;
17851785
ObjectAddress nsp;
1786+
ObjectAddresses *refobjs;
17861787
ListCell *lc;
17871788

17881789
/*
@@ -1825,27 +1826,26 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
18251826
*/
18261827
recordDependencyOnOwner(ExtensionRelationId, extensionOid, extOwner);
18271828

1828-
myself.classId = ExtensionRelationId;
1829-
myself.objectId = extensionOid;
1830-
myself.objectSubId = 0;
1829+
refobjs = new_object_addresses();
18311830

1832-
nsp.classId = NamespaceRelationId;
1833-
nsp.objectId = schemaOid;
1834-
nsp.objectSubId = 0;
1831+
ObjectAddressSet(myself, ExtensionRelationId, extensionOid);
18351832

1836-
recordDependencyOn(&myself, &nsp, DEPENDENCY_NORMAL);
1833+
ObjectAddressSet(nsp, NamespaceRelationId, schemaOid);
1834+
add_exact_object_address(&nsp, refobjs);
18371835

18381836
foreach(lc, requiredExtensions)
18391837
{
18401838
Oid reqext = lfirst_oid(lc);
18411839
ObjectAddress otherext;
18421840

1843-
otherext.classId = ExtensionRelationId;
1844-
otherext.objectId = reqext;
1845-
otherext.objectSubId = 0;
1846-
1847-
recordDependencyOn(&myself, &otherext, DEPENDENCY_NORMAL);
1841+
ObjectAddressSet(otherext, ExtensionRelationId, reqext);
1842+
add_exact_object_address(&otherext, refobjs);
18481843
}
1844+
1845+
/* Record all of them (this includes duplicate elimination) */
1846+
record_object_address_dependencies(&myself, refobjs, DEPENDENCY_NORMAL);
1847+
free_object_addresses(refobjs);
1848+
18491849
/* Post creation hook for new extension */
18501850
InvokeObjectPostCreateHook(ExtensionRelationId, extensionOid, 0);
18511851

0 commit comments

Comments
 (0)
Failed to load comments.