Skip to main content

uqa_execution/mutation/entry/
context.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Name resolution before command entry and fresh execution inputs inside the transaction.
8use crate::mutation::{
9    statement::context::MutationStatementContext, views::commands::SourceOutputPruning,
10};
11use uqa_sql::{
12    routines::RoutineResolution,
13    semantics::{conflict::InferenceContext, returning::ReturningAnalysisContext},
14    SQLError, SQLResult,
15};
16
17pub trait MutationTargetResolution {
18    fn resolve_target(&self, name: &str, bound: bool) -> Result<String, SQLError>;
19}
20pub struct MutationCommandContext<'a, S: Clone + 'static> {
21    pub statement: MutationStatementContext<'a, S>,
22    pub inference: InferenceContext<'a>,
23    pub returning: ReturningAnalysisContext<'a>,
24    pub prune_source_outputs: SourceOutputPruning,
25}
26pub type MutationCommand<'a, S> =
27    Box<dyn FnOnce(&MutationCommandContext<'_, S>) -> Result<SQLResult, SQLError> + 'a>;
28pub trait MutationCommandBoundary<S: Clone + 'static> {
29    fn with_command(&self, command: MutationCommand<'_, S>) -> Result<SQLResult, SQLError>;
30}
31pub struct MutationEntryContext<'a, S: Clone + 'static> {
32    pub targets: &'a dyn MutationTargetResolution,
33    pub transactions: &'a dyn MutationCommandBoundary<S>,
34    pub routines: &'a dyn RoutineResolution,
35}