Skip to main content

uqa_sql/binding/production/
resolution.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7use crate::catalog::resolution::{RelationLookupMode, RelationNameResolution};
8use crate::SQLError;
9use uqa_core::memory::{MemoryReservation, Produced, ProductionControl};
10
11/// The namespace buffers and their constructor lease move together. Lookup mode is inline state and cannot replace those buffers.
12pub struct BindingResolution {
13    value: RelationNameResolution,
14    _memory: Option<MemoryReservation>,
15}
16impl BindingResolution {
17    pub fn from_produced(value: Produced<RelationNameResolution>) -> Self {
18        let (value, memory) = value.into_parts();
19        Self {
20            value,
21            _memory: memory,
22        }
23    }
24    pub fn copy_with_control(&self, control: &ProductionControl<'_>) -> Result<Self, SQLError> {
25        self.value
26            .copy_with_control(control)
27            .map(Self::from_produced)
28    }
29    pub fn set_lookup_mode(&mut self, mode: RelationLookupMode) -> RelationLookupMode {
30        self.value.set_lookup_mode(mode)
31    }
32}
33impl From<RelationNameResolution> for BindingResolution {
34    fn from(value: RelationNameResolution) -> Self {
35        Self {
36            value,
37            _memory: None,
38        }
39    }
40}
41impl Clone for BindingResolution {
42    fn clone(&self) -> Self {
43        self.value.clone().into()
44    }
45}
46impl std::ops::Deref for BindingResolution {
47    type Target = RelationNameResolution;
48    fn deref(&self) -> &Self::Target {
49        &self.value
50    }
51}