pub trait Routine<C: Context>: Send + Sync {
// Required methods
fn info(&self) -> &RoutineInfo;
fn return_type(&self, input_types: &[Type]) -> Type;
fn execute(
&self,
ctx: &mut C,
args: &Columns,
) -> Result<Columns, RoutineError>;
// Provided methods
fn accepted_types(&self) -> InputTypes { ... }
fn propagates_options(&self) -> bool { ... }
fn call(&self, ctx: &mut C, args: &Columns) -> Result<Columns, RoutineError> { ... }
}Expand description
The generic, function-and-procedure-agnostic contract. Implementors pick a
context type (FunctionContext or ProcedureContext); that choice IS the
function-vs-procedure declaration and statically determines whether the
routine can access the transaction.
Function-only concerns (kinds, accumulator) live on the Function
sub-trait. Procedures get a marker sub-trait Procedure with a blanket
impl, so existing procedure impls require no extra boilerplate.
Required Methods§
fn info(&self) -> &RoutineInfo
fn return_type(&self, input_types: &[Type]) -> Type
Sourcefn execute(&self, ctx: &mut C, args: &Columns) -> Result<Columns, RoutineError>
fn execute(&self, ctx: &mut C, args: &Columns) -> Result<Columns, RoutineError>
Execute the routine.
Takes ctx by &mut so procedure routines can reborrow
ctx.tx as &mut Transaction. Function routines don’t mutate the
context - the &mut is a no-op for them, since the env fields are
shared references whose mutability isn’t projected through.