Skip to main content

uqa_execution/mutation/
events.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! The AFTER row events a command queues as it stages its rows.
8
9use super::triggers::{
10    context::TriggerContext,
11    events::{AfterRowEventSink, AfterRowEvents},
12};
13use uqa_core::DocId;
14use uqa_storage::document_store::Document;
15
16/// The AFTER row events of one command, in the order it staged its rows.
17#[derive(Default)]
18pub struct MutationEventQueue {
19    after_rows: AfterRowEvents,
20}
21
22impl MutationEventQueue {
23    pub fn after_rows_mut(&mut self) -> &mut AfterRowEvents {
24        &mut self.after_rows
25    }
26
27    pub fn append_after_rows(
28        &mut self,
29        events: Vec<crate::mutation::triggers::AfterRowTriggerEvent>,
30        context: &TriggerContext<'_>,
31    ) -> Result<(), uqa_sql::SQLError> {
32        for event in events {
33            self.after_rows.push_event(event, context)?;
34        }
35        Ok(())
36    }
37
38    pub fn into_after_rows(self) -> AfterRowEvents {
39        self.after_rows
40    }
41}
42
43pub struct ReferentialRewritePreparation<'a> {
44    /// The table of the foreign key whose action rewrites the row.
45    pub constraint_table: &'a str,
46    pub table: &'a str,
47    pub doc_id: DocId,
48    pub old_document: Document,
49    pub proposed_document: Document,
50    pub updated_columns: Vec<String>,
51}