Skip to main content

uqa_execution/query/
routine_invocation.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Invocation services for compiled SQL routines.
8
9use crate::functions::SQLTableFunctionResult;
10use uqa_core::Value;
11use uqa_sql::{ast::FunctionBinding, routines::SQLUserFunction, SQLError};
12
13/// Execute a routine through the caller's transaction and session context.
14pub trait SQLRoutineInvoker {
15    fn has_user_function(
16        &self,
17        name: &str,
18        binding: Option<&FunctionBinding>,
19    ) -> Result<bool, SQLError>;
20    fn user_function_returns_set(
21        &self,
22        name: &str,
23        binding: Option<&FunctionBinding>,
24        arguments: &[(Option<String>, Value)],
25    ) -> Option<Result<bool, SQLError>>;
26    fn call_user_scalar_function(
27        &self,
28        name: &str,
29        binding: Option<&FunctionBinding>,
30        arguments: &[(Option<String>, Value)],
31    ) -> Option<Result<Value, SQLError>>;
32    fn call_user_table_function(
33        &self,
34        name: &str,
35        binding: Option<&FunctionBinding>,
36        arguments: &[(Option<String>, Value)],
37    ) -> Option<Result<SQLTableFunctionResult, SQLError>>;
38    /// Enforce EXECUTE on a user routine that a FROM item calls, as `PostgreSQL` checks it when it initializes the scan, before the routine runs for any row.
39    fn require_user_function_execute(&self, function: &SQLUserFunction) -> Result<(), SQLError>;
40}