mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Switch to multi-inserts when registering dependencies for many code paths
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
This commit is contained in:
@ -1696,6 +1696,7 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
Relation relation;
|
||||
ObjectAddress myself,
|
||||
referenced;
|
||||
ObjectAddresses *addrs;
|
||||
bool is_replace;
|
||||
|
||||
/*
|
||||
@ -1836,39 +1837,34 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
if (is_replace)
|
||||
deleteDependencyRecordsFor(TransformRelationId, transformid, true);
|
||||
|
||||
addrs = new_object_addresses();
|
||||
|
||||
/* make dependency entries */
|
||||
myself.classId = TransformRelationId;
|
||||
myself.objectId = transformid;
|
||||
myself.objectSubId = 0;
|
||||
ObjectAddressSet(myself, TransformRelationId, transformid);
|
||||
|
||||
/* dependency on language */
|
||||
referenced.classId = LanguageRelationId;
|
||||
referenced.objectId = langid;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
ObjectAddressSet(referenced, LanguageRelationId, langid);
|
||||
add_exact_object_address(&referenced, addrs);
|
||||
|
||||
/* dependency on type */
|
||||
referenced.classId = TypeRelationId;
|
||||
referenced.objectId = typeid;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
ObjectAddressSet(referenced, TypeRelationId, typeid);
|
||||
add_exact_object_address(&referenced, addrs);
|
||||
|
||||
/* dependencies on functions */
|
||||
if (OidIsValid(fromsqlfuncid))
|
||||
{
|
||||
referenced.classId = ProcedureRelationId;
|
||||
referenced.objectId = fromsqlfuncid;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
ObjectAddressSet(referenced, ProcedureRelationId, fromsqlfuncid);
|
||||
add_exact_object_address(&referenced, addrs);
|
||||
}
|
||||
if (OidIsValid(tosqlfuncid))
|
||||
{
|
||||
referenced.classId = ProcedureRelationId;
|
||||
referenced.objectId = tosqlfuncid;
|
||||
referenced.objectSubId = 0;
|
||||
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
|
||||
ObjectAddressSet(referenced, ProcedureRelationId, tosqlfuncid);
|
||||
add_exact_object_address(&referenced, addrs);
|
||||
}
|
||||
|
||||
record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL);
|
||||
free_object_addresses(addrs);
|
||||
|
||||
/* dependency on extension */
|
||||
recordDependencyOnCurrentExtension(&myself, is_replace);
|
||||
|
||||
|
Reference in New Issue
Block a user