uqa_execution/mutation/entry/
context.rs1use crate::mutation::output::MutationOutput;
9use crate::mutation::{
10 statement::context::MutationStatementContext, views::commands::SourceOutputPruning,
11};
12use uqa_sql::{
13 routines::RoutineResolution,
14 semantics::{conflict::InferenceContext, returning::ReturningAnalysisContext},
15 SQLError,
16};
17
18pub trait MutationTargetResolution {
19 fn resolve_target(&self, name: &str, bound: bool) -> Result<String, SQLError>;
20 fn resolve_target_with_control(
22 &self,
23 name: &str,
24 bound: bool,
25 control: &uqa_core::memory::ProductionControl<'_>,
26 ) -> Result<uqa_core::memory::Produced<String>, SQLError> {
27 control.check()?;
28 let resolved = self.resolve_target(name, bound)?;
29 Ok(control.copy_text(&resolved)?)
30 }
31}
32pub struct MutationCommandContext<'a, S: Clone + 'static> {
33 pub statement: MutationStatementContext<'a, S>,
34 pub inference: InferenceContext<'a>,
35 pub returning: ReturningAnalysisContext<'a>,
36 pub prune_source_outputs: SourceOutputPruning,
37}
38pub type MutationCommand<'a, S> =
39 Box<dyn FnOnce(&MutationCommandContext<'_, S>) -> Result<MutationOutput, SQLError> + 'a>;
40pub trait MutationCommandBoundary<S: Clone + 'static> {
41 fn with_command(&self, command: MutationCommand<'_, S>) -> Result<MutationOutput, SQLError>;
42}
43pub struct MutationEntryContext<'a, S: Clone + 'static> {
44 pub targets: &'a dyn MutationTargetResolution,
45 pub transactions: &'a dyn MutationCommandBoundary<S>,
46 pub routines: &'a dyn RoutineResolution,
47}