Skip to main content

register_admin_function_in

Function register_admin_function_in 

Source
fn register_admin_function_in(
    admin_registry: &FunctionRegistry,
    normal_registry: &FunctionRegistry,
    func: impl Into<ScalarFunctionFactory>,
) -> FunctionRegistrationResult
Expand description

Core implementation of register_admin_function against a pair of registries, parameterized so tests can exercise it with local registries.

Locking: the ADMIN-registry write lock is acquired first, then a read lock on the normal registry, and the normal-registry guard (bound to normal_functions) is kept alive through both the normal-name check and the ADMIN insertion below. This is the only code path that holds both registries’ locks, so the ADMIN -> FUNCTION acquisition order is consistent and a concurrent normal-registry registration cannot slip in between the check and the ADMIN insert and be shadowed.

The enforced contract is one-way: it only guards the ADMIN registration against names already present in the normal registry. A later ordinary FunctionRegistry::register may still install the same name in the normal registry because the normal registry keeps its legacy replace semantics.