pub struct FunctionRegistry { /* private fields */ }Expand description
Registry for scalar, aggregate, and window functions, keyed by
(name, num_args).
Lookup strategy (§9.5):
- A compatible exact application registration, across all function kinds.
- A compatible variadic application registration.
- An exact entry in the built-in/base layer requested by the caller.
- An arity-compatible variadic entry in that base layer.
- A known same-kind name with incompatible arity returns a function that raises SQLite’s “wrong number of arguments” error when invoked.
Noneif neither layer contains a usable same-kind entry.
Implementations§
Source§impl FunctionRegistry
impl FunctionRegistry
Sourcepub fn clone_from_arc(arc: &Arc<Self>) -> Self
pub fn clone_from_arc(arc: &Arc<Self>) -> Self
Create a mutable clone of a registry from an Arc reference.
This is used by the UDF registration API to produce a new registry containing the existing functions plus the newly registered UDF.
Sourcepub fn resolve_application_function(
&self,
name: &str,
num_args: i32,
) -> Option<ApplicationFunctionResolution>
pub fn resolve_application_function( &self, name: &str, num_args: i32, ) -> Option<ApplicationFunctionResolution>
Resolve a compatible application registration across all function kinds.
An exact application key wins over a compatible application variadic,
independent of kind or registration order. None means no application
overload accepts this call; callers may then resolve built-ins.
Sourcepub fn resolve_application_function_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<ApplicationFunctionResolution>
pub fn resolve_application_function_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ApplicationFunctionResolution>
Precanonicalized counterpart to Self::resolve_application_function.
Sourcepub fn contains_application_function(&self, name: &str) -> bool
pub fn contains_application_function(&self, name: &str) -> bool
Whether any application overload is registered under this name.
Sourcepub fn register_application_scalar_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<DisplacedApplicationFunction>where
F: ScalarFunction + 'static,
pub fn register_application_scalar_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<DisplacedApplicationFunction>where
F: ScalarFunction + 'static,
Register an application-defined scalar using caller-frozen metadata.
This shares a cross-kind namespace with application aggregate and window
registrations. Replacing an identical (name, declared_arity) key
therefore displaces the previous application entry regardless of kind.
Sourcepub fn register_application_aggregate_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> Option<DisplacedApplicationFunction>where
F: AggregateFunction + 'static,
F::State: 'static,
pub fn register_application_aggregate_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> Option<DisplacedApplicationFunction>where
F: AggregateFunction + 'static,
F::State: 'static,
Register an application-defined aggregate using caller-frozen metadata.
The returned token owns any same-key application entry displaced across scalar, aggregate, or window kinds.
Sourcepub fn register_application_window_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<DisplacedApplicationFunction>)where
F: WindowFunction + 'static,
F::State: 'static,
pub fn register_application_window_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<DisplacedApplicationFunction>)where
F: WindowFunction + 'static,
F::State: 'static,
Register an application-defined window function using frozen metadata.
SQLite window registrations retain an ordinary aggregate call form. The returned window Arc and aggregate bridge share the same erased function object and frozen arity contract.
Sourcepub fn register_scalar<F>(
&mut self,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
pub fn register_scalar<F>(
&mut self,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
Register a scalar function, keyed by (name, num_args).
Overwrites any existing function with the same key. Returns the previous function if one existed.
Sourcepub fn register_scalar_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
pub fn register_scalar_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
Register a scalar function under caller-precomputed identity and arity.
This variant never calls user metadata. It is intended for publication paths that capture metadata before taking a registry snapshot, so a reentrant metadata callback cannot make a stale clone overwrite a nested registration. The key and immutable arity contract must agree.
Sourcepub fn register_scalar_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
pub fn register_scalar_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
deterministic: bool,
consumes_argument_collation: bool,
function: F,
) -> Option<Arc<dyn ScalarFunction>>where
F: ScalarFunction + 'static,
Register a scalar function with caller-captured metadata.
No user metadata callback runs in this method. The registry key and runtime acceptance contract are both derived from the same immutable arity value.
Sourcepub fn register_aggregate<F>(
&mut self,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
pub fn register_aggregate<F>(
&mut self,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
Register an aggregate function using the type-erased adapter.
Overwrites any existing function with the same (name, num_args) key.
Sourcepub fn register_aggregate_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
pub fn register_aggregate_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
Register an aggregate function under caller-precomputed identity and arity.
Returns the displaced adapter, if any. No user metadata callback runs here. The key and immutable arity contract must agree.
Sourcepub fn register_aggregate_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
pub fn register_aggregate_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> Option<Arc<ErasedAggregateFunction>>where
F: AggregateFunction + 'static,
F::State: 'static,
Register an aggregate function with caller-captured metadata.
No user metadata callback runs in this method. The registry key and runtime acceptance contract share one immutable arity value.
Sourcepub fn register_window<F>(
&mut self,
function: F,
) -> Option<Arc<ErasedWindowFunction>>where
F: WindowFunction + 'static,
F::State: 'static,
pub fn register_window<F>(
&mut self,
function: F,
) -> Option<Arc<ErasedWindowFunction>>where
F: WindowFunction + 'static,
F::State: 'static,
Register a window function using the type-erased adapter.
Overwrites any existing function with the same (name, num_args) key.
Sourcepub fn register_window_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<Arc<ErasedWindowFunction>>)where
F: WindowFunction + 'static,
F::State: 'static,
pub fn register_window_keyed<F>(
&mut self,
key: FunctionKey,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<Arc<ErasedWindowFunction>>)where
F: WindowFunction + 'static,
F::State: 'static,
Register a window function under caller-precomputed identity and arity.
The returned first Arc is the newly inserted erased adapter; the second is the displaced adapter, if any. No user metadata callback runs here. The key and immutable arity contract must agree.
Sourcepub fn register_window_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<Arc<ErasedWindowFunction>>)where
F: WindowFunction + 'static,
F::State: 'static,
pub fn register_window_captured<F>(
&mut self,
name: &str,
arity: FunctionArity,
function: F,
) -> (Arc<ErasedWindowFunction>, Option<Arc<ErasedWindowFunction>>)where
F: WindowFunction + 'static,
F::State: 'static,
Register a window function with caller-captured metadata.
No user metadata callback runs in this method. The registry key and runtime acceptance contract share one immutable arity value.
Sourcepub fn find_scalar(
&self,
name: &str,
num_args: i32,
) -> Option<Arc<dyn ScalarFunction>>
pub fn find_scalar( &self, name: &str, num_args: i32, ) -> Option<Arc<dyn ScalarFunction>>
Look up a scalar function by (name, num_args).
Tries exact match first, then falls back to an arity-compatible
variadic version (name, -1) if no exact match exists.
Sourcepub fn find_scalar_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<Arc<dyn ScalarFunction>>
pub fn find_scalar_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<Arc<dyn ScalarFunction>>
Look up a scalar function by already-uppercased name (avoids allocation).
Used by the VDBE engine where P4::FuncName values are already
canonicalized by codegen.
Sourcepub fn resolve_scalar(
&self,
name: &str,
num_args: i32,
) -> Option<ResolvedScalarFunction>
pub fn resolve_scalar( &self, name: &str, num_args: i32, ) -> Option<ResolvedScalarFunction>
Resolve a scalar implementation and all execution metadata in one registry traversal.
Sourcepub fn resolve_scalar_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<ResolvedScalarFunction>
pub fn resolve_scalar_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ResolvedScalarFunction>
Precanonicalized counterpart to Self::resolve_scalar.
Sourcepub fn find_aggregate(
&self,
name: &str,
num_args: i32,
) -> Option<Arc<ErasedAggregateFunction>>
pub fn find_aggregate( &self, name: &str, num_args: i32, ) -> Option<Arc<ErasedAggregateFunction>>
Look up an aggregate function by (name, num_args).
Tries exact match first, then falls back to variadic (name, -1).
Sourcepub fn find_aggregate_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<Arc<ErasedAggregateFunction>>
pub fn find_aggregate_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<Arc<ErasedAggregateFunction>>
Look up an aggregate function by already-uppercased name (avoids allocation).
Sourcepub fn find_window(
&self,
name: &str,
num_args: i32,
) -> Option<Arc<ErasedWindowFunction>>
pub fn find_window( &self, name: &str, num_args: i32, ) -> Option<Arc<ErasedWindowFunction>>
Look up a window function by (name, num_args).
Tries exact match first, then falls back to variadic (name, -1).
Sourcepub fn contains_scalar(&self, name: &str) -> bool
pub fn contains_scalar(&self, name: &str) -> bool
Whether the registry contains any scalar function with this name (any arg count).
Sourcepub fn contains_aggregate(&self, name: &str) -> bool
pub fn contains_aggregate(&self, name: &str) -> bool
Whether the registry contains any aggregate function with this name (any arg count).
Sourcepub fn contains_window(&self, name: &str) -> bool
pub fn contains_window(&self, name: &str) -> bool
Whether the registry contains any window function with this name (any arg count).
Sourcepub fn scalar_accepts_arg_count(
&self,
name: &str,
num_args: i32,
) -> Option<bool>
pub fn scalar_accepts_arg_count( &self, name: &str, num_args: i32, ) -> Option<bool>
Return whether a known scalar function accepts the SQL-visible arity.
None means the name is not registered as a scalar function at all.
Unlike Self::find_scalar, this never constructs or invokes a
wrong-arity sentinel, so preparation-only validation remains free of
user-function side effects.
Sourcepub fn scalar_schema_safety(
&self,
name: &str,
num_args: i32,
) -> Option<ScalarSchemaSafety>
pub fn scalar_schema_safety( &self, name: &str, num_args: i32, ) -> Option<ScalarSchemaSafety>
Return the frozen schema-safety policy for the resolved scalar entry.
Exact arity wins over an arity-compatible variadic entry. Missing or
inconsistent internal metadata fails closed as ScalarSchemaSafety::Never.
Sourcepub fn scalar_schema_safety_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<ScalarSchemaSafety>
pub fn scalar_schema_safety_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ScalarSchemaSafety>
Precanonicalized counterpart to Self::scalar_schema_safety.
Sourcepub fn scalar_is_deterministic(&self, name: &str, num_args: i32) -> Option<bool>
pub fn scalar_is_deterministic(&self, name: &str, num_args: i32) -> Option<bool>
Return whether the resolved scalar is statically eligible for schema
expressions. Conditional built-in date/time entries return true here
and are checked again against evaluated arguments at execution time.
Sourcepub fn scalar_consumes_argument_collation(
&self,
name: &str,
num_args: i32,
) -> Option<bool>
pub fn scalar_consumes_argument_collation( &self, name: &str, num_args: i32, ) -> Option<bool>
Return the frozen argument-collation contract for the resolved scalar.
The trait callback is captured once at registration. Execution and schema dependency analysis never re-enter arbitrary user metadata.
Sourcepub fn scalar_consumes_argument_collation_precanonical(
&self,
canonical: &str,
num_args: i32,
) -> Option<bool>
pub fn scalar_consumes_argument_collation_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<bool>
Precanonicalized counterpart to
Self::scalar_consumes_argument_collation.
Sourcepub fn aggregate_accepts_arg_count(
&self,
name: &str,
num_args: i32,
) -> Option<bool>
pub fn aggregate_accepts_arg_count( &self, name: &str, num_args: i32, ) -> Option<bool>
Return whether a known aggregate function accepts the SQL-visible arity.
None means the name is not registered as an aggregate function at
all. This is the side-effect-free counterpart to
Self::find_aggregate for preparation-only validation.
Sourcepub fn window_accepts_arg_count(
&self,
name: &str,
num_args: i32,
) -> Option<bool>
pub fn window_accepts_arg_count( &self, name: &str, num_args: i32, ) -> Option<bool>
Return whether a known window function accepts the SQL-visible arity.
None means the name is not registered as a window function at all.
This is useful for callers that may execute optimized window paths
without invoking the returned function’s step() method, where the
wrong-arity sentinel from find_window would otherwise be bypassed.
Sourcepub fn aggregate_names_lowercase(&self) -> Vec<String>
pub fn aggregate_names_lowercase(&self) -> Vec<String>
Return deduplicated lowercase names of all registered aggregate functions.
Used by the codegen thread-local to recognize custom aggregate UDFs.