diff --git a/core/vdbe/builder.rs b/core/vdbe/builder.rs index 7d45c5f4b..4a32c9dad 100644 --- a/core/vdbe/builder.rs +++ b/core/vdbe/builder.rs @@ -1,5 +1,6 @@ use std::{cell::Cell, cmp::Ordering, rc::Rc, sync::Arc}; +use bitflags::bitflags; use tracing::{instrument, Level}; use turso_sqlite3_parser::ast::{self, TableInternalId}; @@ -110,6 +111,7 @@ pub struct ProgramBuilder { nested_level: usize, init_label: BranchOffset, start_offset: BranchOffset, + flags: ProgramBuilderFlags, } #[derive(Debug, Clone)] @@ -133,6 +135,12 @@ pub enum QueryMode { Explain, } +bitflags! { + pub struct ProgramBuilderFlags: u8 { + const CaptureChanges = 0x01; /* emit plans with capture changes instructurs for INSERT/DELETE/UPDATE operations */ + } +} + impl From for QueryMode { fn from(stmt: ast::Cmd) -> Self { match stmt { @@ -149,7 +157,11 @@ pub struct ProgramBuilderOpts { } impl ProgramBuilder { - pub fn new(query_mode: QueryMode, opts: ProgramBuilderOpts) -> Self { + pub fn new( + query_mode: QueryMode, + flags: ProgramBuilderFlags, + opts: ProgramBuilderOpts, + ) -> Self { Self { table_reference_counter: TableRefIdCounter::new(), next_free_register: 1, @@ -172,9 +184,14 @@ impl ProgramBuilder { // These labels will be filled when `prologue()` is called init_label: BranchOffset::Placeholder, start_offset: BranchOffset::Placeholder, + flags, } } + pub fn flags(&self) -> &ProgramBuilderFlags { + &self.flags + } + pub fn extend(&mut self, opts: &ProgramBuilderOpts) { self.insns.reserve(opts.approx_num_insns); self.cursor_ref.reserve(opts.num_cursors);