Skip to main content

FunctionRegistry

Struct FunctionRegistry 

Source
pub struct FunctionRegistry { /* private fields */ }
Expand description

Registry for scalar, aggregate, and window functions, keyed by (name, num_args).

Lookup strategy (§9.5):

  1. A compatible exact application registration, across all function kinds.
  2. A compatible variadic application registration.
  3. An exact entry in the built-in/base layer requested by the caller.
  4. An arity-compatible variadic entry in that base layer.
  5. A known same-kind name with incompatible arity returns a function that raises SQLite’s “wrong number of arguments” error when invoked.
  6. None if neither layer contains a usable same-kind entry.

Implementations§

Source§

impl FunctionRegistry

Source

pub fn new() -> Self

Create an empty registry.

Source

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.

Source

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.

Source

pub fn resolve_application_function_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ApplicationFunctionResolution>

Precanonicalized counterpart to Self::resolve_application_function.

Source

pub fn contains_application_function(&self, name: &str) -> bool

Whether any application overload is registered under this name.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn resolve_scalar( &self, name: &str, num_args: i32, ) -> Option<ResolvedScalarFunction>

Resolve a scalar implementation and all execution metadata in one registry traversal.

Source

pub fn resolve_scalar_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ResolvedScalarFunction>

Precanonicalized counterpart to Self::resolve_scalar.

Source

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).

Source

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).

Source

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).

Source

pub fn contains_scalar(&self, name: &str) -> bool

Whether the registry contains any scalar function with this name (any arg count).

Source

pub fn contains_aggregate(&self, name: &str) -> bool

Whether the registry contains any aggregate function with this name (any arg count).

Source

pub fn contains_window(&self, name: &str) -> bool

Whether the registry contains any window function with this name (any arg count).

Source

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.

Source

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.

Source

pub fn scalar_schema_safety_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<ScalarSchemaSafety>

Precanonicalized counterpart to Self::scalar_schema_safety.

Source

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.

Source

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.

Source

pub fn scalar_consumes_argument_collation_precanonical( &self, canonical: &str, num_args: i32, ) -> Option<bool>

Precanonicalized counterpart to Self::scalar_consumes_argument_collation.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for FunctionRegistry

Source§

fn default() -> FunctionRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more