uqa-engine 0.6.2

Engine: schema-aware table store, catalog restore, transactions
Documentation
//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//

//! Statement and retained-resource adapters for catalog-aware host value input.

use crate::Engine;
use uqa_core::memory::{Produced, ProductionControl};
use uqa_sql::{SQLError, SQLParam};

impl Engine {
    /// Construct typed range bounds with the native statement scope; SQL owns endpoint conversion and Execution invokes selected catalog support.
    pub fn create_range_parameter_with_control(
        &self,
        type_name: &str,
        bounds: uqa_sql::params::RangeParameterBounds<'_>,
        control: &ProductionControl<'_>,
    ) -> Result<Produced<SQLParam>, SQLError> {
        self.with_direct_query_snapshot(
            false,
            |engine| {
                uqa_sql::params::create_range_parameter_with_control(
                    type_name, bounds, engine, engine, control,
                )
            },
            std::convert::identity,
        )
    }

    /// Normalize typed range members and validate an enclosing domain in the native statement scope.
    pub fn create_multirange_parameter_with_control(
        &self,
        type_name: &str,
        members: &[SQLParam],
        control: &ProductionControl<'_>,
    ) -> Result<Produced<SQLParam>, SQLError> {
        self.with_direct_query_snapshot(
            false,
            |engine| {
                uqa_sql::params::create_multirange_parameter_with_control(
                    type_name, members, engine, engine, control,
                )
            },
            std::convert::identity,
        )
    }

    /// Construct a typed host record in the native statement scope. SQL owns attribute selection, source binding, scalar casts and domain checks.
    pub fn create_record_parameter_with_control(
        &self,
        type_name: &str,
        fields: &[SQLParam],
        control: &ProductionControl<'_>,
    ) -> Result<Produced<SQLParam>, SQLError> {
        self.with_direct_query_snapshot(
            false,
            |engine| {
                uqa_sql::params::create_record_parameter_with_control(
                    type_name, fields, engine, engine, control,
                )
            },
            std::convert::identity,
        )
    }

    /// Construct a typed host array in the session's native statement/catalog scope. SQL owns parameter identities, scalar conversion, dimensions and domain constraints.
    pub fn create_array_parameter_with_control(
        &self,
        type_name: &str,
        dimensions: &[usize],
        lower_bounds: &[i32],
        elements: &[SQLParam],
        control: &ProductionControl<'_>,
    ) -> Result<Produced<SQLParam>, SQLError> {
        self.with_direct_query_snapshot(
            false,
            |engine| {
                uqa_sql::params::create_array_parameter_with_control(
                    type_name,
                    dimensions,
                    lower_bounds,
                    elements,
                    engine,
                    engine,
                    control,
                )
            },
            std::convert::identity,
        )
    }

    /// Create a typed parameter from external text, or a typed SQL NULL from `None`. Type input runs with the session's current catalog, privileges and presentation settings. Domain checks and input callbacks share native transaction admission, commit and failure recovery; the returned parameter retains the supplied production allowance.
    pub fn create_typed_parameter_with_control(
        &self,
        type_name: &str,
        text: Option<&str>,
        control: &ProductionControl<'_>,
    ) -> Result<Produced<SQLParam>, SQLError> {
        self.with_direct_query_snapshot(
            false,
            |engine| {
                uqa_sql::params::create_typed_parameter_with_control(
                    type_name, text, engine, engine, control,
                )
            },
            std::convert::identity,
        )
    }
}