Skip to main content

linkrs_query/executor/expression/functions/registry/
custom.rs

1use super::super::CustomFunction;
2use super::FunctionRegistry;
3
4impl FunctionRegistry {
5    /// Registering a custom function (full form)
6    pub fn register_custom_full(&mut self, function: CustomFunction) {
7        let upper_name = function.name.to_uppercase();
8        self.custom_functions.insert(upper_name, function);
9    }
10
11    /// Remove a non-dynamic custom function by name.
12    ///
13    /// Dynamic UDFs must go through `unload_dynamic_udf` so the library
14    /// handle is dropped exactly once; builtins are never removed here.
15    /// Returns true when an entry was removed.
16    pub fn unregister_custom(&mut self, name: &str) -> bool {
17        let upper = name.to_uppercase();
18        if self.dynamic_libraries.contains_key(&upper)
19            || self.builtin_functions.contains_key(&upper)
20        {
21            return false;
22        }
23        self.custom_functions.remove(&upper).is_some()
24    }
25    /// Obtaining a custom function
26    pub fn get_custom(&self, name: &str) -> Option<&CustomFunction> {
27        // Convert to uppercase for case-insensitive lookup
28        let upper_name = name.to_uppercase();
29        self.custom_functions.get(&upper_name)
30    }
31}