From 8febfd1855450f50f17419def41c2ea9bcf994d5 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Sat, 5 Sep 2020 21:33:53 +0900 Subject: Switch to multi-inserts when registering dependencies for many code paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit improves the dependency registrations by taking advantage of the preliminary work done in 63110c62, to group together the insertion of dependencies of the same type to pg_depend. With the current layer of routines available, and as only dependencies of the same type can be grouped, there are code paths still doing more than one multi-insert when it is necessary to register dependencies of multiple types (constraint and index creation are two cases doing that). While on it, this refactors some of the code to use ObjectAddressSet() when manipulating object addresses. Author: Daniel Gustafsson, Michael Paquier Reviewed-by: Andres Freund, Álvaro Herrera Discussion: https://postgr.es/m/20200807061619.GA23955@paquier.xyz --- src/backend/commands/proclang.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/backend/commands/proclang.c') diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 14153426bdd..8ef60374f59 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -57,6 +57,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) bool is_update; ObjectAddress myself, referenced; + ObjectAddresses *addrs; /* * Check permission @@ -186,30 +187,29 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) /* dependency on extension */ recordDependencyOnCurrentExtension(&myself, is_update); + addrs = new_object_addresses(); + /* dependency on the PL handler function */ - referenced.classId = ProcedureRelationId; - referenced.objectId = handlerOid; - referenced.objectSubId = 0; - recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); + ObjectAddressSet(referenced, ProcedureRelationId, handlerOid); + add_exact_object_address(&referenced, addrs); /* dependency on the inline handler function, if any */ if (OidIsValid(inlineOid)) { - referenced.classId = ProcedureRelationId; - referenced.objectId = inlineOid; - referenced.objectSubId = 0; - recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); + ObjectAddressSet(referenced, ProcedureRelationId, inlineOid); + add_exact_object_address(&referenced, addrs); } /* dependency on the validator function, if any */ if (OidIsValid(valOid)) { - referenced.classId = ProcedureRelationId; - referenced.objectId = valOid; - referenced.objectSubId = 0; - recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); + ObjectAddressSet(referenced, ProcedureRelationId, valOid); + add_exact_object_address(&referenced, addrs); } + record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); + free_object_addresses(addrs); + /* Post creation hook for new procedural language */ InvokeObjectPostCreateHook(LanguageRelationId, myself.objectId, 0); -- cgit v1.2.3