Skip to main content

uqa_sql/prepared/
planning.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Prepared-plan selection contract and identity-checked cache updates.
8
9use crate::{plan::UnifiedPlan, SQLError, SQLParam};
10
11pub trait PreparedPlanProvider {
12    fn plan_for_execution(
13        &self,
14        name: &str,
15        parameters: &[SQLParam],
16    ) -> Result<Option<UnifiedPlan>, SQLError>;
17}
18
19/// A successful replacement analysis and the namespace it used, published together against the original definition identity.
20pub struct PreparedPlanAnalysis {
21    pub logical_plan: std::sync::Arc<UnifiedPlan>,
22    pub effective_search_path: Option<crate::catalog::resolution::EffectiveSearchPath>,
23    pub dependencies: super::dependencies::PreparedAnalysisDependencies,
24    pub dependency_snapshot: Option<super::dependencies::PreparedDependencySnapshot>,
25}
26
27pub struct PreparedPlanUpdate {
28    pub reanalyzed: Option<PreparedPlanAnalysis>,
29    pub generic_plan: Option<UnifiedPlan>,
30    pub generic_cost: Option<f64>,
31    pub custom_cost: Option<f64>,
32}