mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-03 23:34:24 +01:00
small renames
This commit is contained in:
14
core/lib.rs
14
core/lib.rs
@@ -278,7 +278,7 @@ impl Database {
|
||||
cache_size: Cell::new(default_cache_size),
|
||||
readonly: Cell::new(false),
|
||||
wal_checkpoint_disabled: Cell::new(false),
|
||||
capture_changes: Cell::new(false),
|
||||
capture_data_changes: Cell::new(false),
|
||||
});
|
||||
if let Err(e) = conn.register_builtins() {
|
||||
return Err(LimboError::ExtensionError(e));
|
||||
@@ -331,7 +331,7 @@ impl Database {
|
||||
cache_size: Cell::new(default_cache_size),
|
||||
readonly: Cell::new(false),
|
||||
wal_checkpoint_disabled: Cell::new(false),
|
||||
capture_changes: Cell::new(false),
|
||||
capture_data_changes: Cell::new(false),
|
||||
});
|
||||
|
||||
if let Err(e) = conn.register_builtins() {
|
||||
@@ -452,7 +452,7 @@ pub struct Connection {
|
||||
cache_size: Cell<i32>,
|
||||
readonly: Cell<bool>,
|
||||
wal_checkpoint_disabled: Cell<bool>,
|
||||
capture_changes: Cell<bool>,
|
||||
capture_data_changes: Cell<bool>,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
@@ -727,11 +727,11 @@ impl Connection {
|
||||
self.cache_size.set(size);
|
||||
}
|
||||
|
||||
pub fn get_capture_changes(&self) -> bool {
|
||||
self.capture_changes.get()
|
||||
pub fn get_capture_data_changes(&self) -> bool {
|
||||
self.capture_data_changes.get()
|
||||
}
|
||||
pub fn set_capture_changes(&self, value: bool) {
|
||||
self.capture_changes.set(value);
|
||||
pub fn set_capture_data_changes(&self, value: bool) {
|
||||
self.capture_data_changes.set(value);
|
||||
}
|
||||
|
||||
#[cfg(feature = "fs")]
|
||||
|
||||
@@ -77,9 +77,9 @@ fn pragma_for(pragma: PragmaName) -> Pragma {
|
||||
PragmaFlags::NeedSchema | PragmaFlags::ReadOnly | PragmaFlags::Result0,
|
||||
&["message"],
|
||||
),
|
||||
CaptureChanges => Pragma::new(
|
||||
CaptureDataChanges => Pragma::new(
|
||||
PragmaFlags::NeedSchema | PragmaFlags::Result0 | PragmaFlags::SchemaReq,
|
||||
&["capture_changes"],
|
||||
&["capture_data_changes"],
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ pub struct TranslateCtx<'a> {
|
||||
/// - First: all `GROUP BY` expressions, in the order they appear in the `GROUP BY` clause.
|
||||
/// - Then: remaining non-aggregate expressions that are not part of `GROUP BY`.
|
||||
pub non_aggregate_expressions: Vec<(&'a Expr, bool)>,
|
||||
/// Cursor id for turso_cdc table (if capture_changes=on is set and query can modify the data)
|
||||
/// Cursor id for turso_cdc table (if capture_data_changes=on is set and query can modify the data)
|
||||
pub cdc_cursor_id: Option<usize>,
|
||||
}
|
||||
|
||||
|
||||
@@ -117,10 +117,10 @@ pub fn translate_insert(
|
||||
let halt_label = program.allocate_label();
|
||||
let loop_start_label = program.allocate_label();
|
||||
|
||||
let capture_changes = program
|
||||
let capture_data_changes = program
|
||||
.flags()
|
||||
.contains(ProgramBuilderFlags::CaptureChanges);
|
||||
let turso_cdc_table = if capture_changes {
|
||||
.contains(ProgramBuilderFlags::CaptureDataChanges);
|
||||
let turso_cdc_table = if capture_data_changes {
|
||||
let Some(turso_cdc_table) = schema.get_table("turso_cdc") else {
|
||||
crate::bail_parse_error!("no such table: {}", "turso_cdc");
|
||||
};
|
||||
|
||||
@@ -118,10 +118,10 @@ pub fn init_loop(
|
||||
"meta_left_joins length does not match tables length"
|
||||
);
|
||||
|
||||
let capture_changes = program
|
||||
let capture_data_changes = program
|
||||
.flags()
|
||||
.contains(ProgramBuilderFlags::CaptureChanges);
|
||||
if capture_changes
|
||||
.contains(ProgramBuilderFlags::CaptureDataChanges);
|
||||
if capture_data_changes
|
||||
&& matches!(
|
||||
mode,
|
||||
OperationMode::INSERT | OperationMode::UPDATE | OperationMode::DELETE
|
||||
|
||||
@@ -73,8 +73,8 @@ pub fn translate(
|
||||
| ast::Stmt::Update(..)
|
||||
);
|
||||
|
||||
let flags = if connection.get_capture_changes() {
|
||||
ProgramBuilderFlags::CaptureChanges
|
||||
let flags = if connection.get_capture_data_changes() {
|
||||
ProgramBuilderFlags::CaptureDataChanges
|
||||
} else {
|
||||
ProgramBuilderFlags::empty()
|
||||
};
|
||||
|
||||
@@ -207,11 +207,11 @@ fn update_pragma(
|
||||
Ok(program)
|
||||
}
|
||||
PragmaName::IntegrityCheck => unreachable!("integrity_check cannot be set"),
|
||||
PragmaName::CaptureChanges => {
|
||||
PragmaName::CaptureDataChanges => {
|
||||
let value = parse_pragma_bool(&value)?;
|
||||
// todo(sivukhin): ideally, we should consistently update capture_changes connection flag only after successfull execution of schema change statement
|
||||
// todo(sivukhin): ideally, we should consistently update capture_data_changes connection flag only after successfull execution of schema change statement
|
||||
// but for now, let's keep it as is...
|
||||
connection.set_capture_changes(value);
|
||||
connection.set_capture_data_changes(value);
|
||||
if value {
|
||||
// make sure that we have turso_cdc table created
|
||||
let columns = vec![
|
||||
@@ -429,8 +429,8 @@ fn query_pragma(
|
||||
PragmaName::IntegrityCheck => {
|
||||
translate_integrity_check(schema, &mut program)?;
|
||||
}
|
||||
PragmaName::CaptureChanges => {
|
||||
program.emit_bool(connection.get_capture_changes(), register);
|
||||
PragmaName::CaptureDataChanges => {
|
||||
program.emit_bool(connection.get_capture_data_changes(), register);
|
||||
program.emit_result_row(register, 1);
|
||||
program.add_pragma_result_column(pragma.to_string());
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ pub enum QueryMode {
|
||||
|
||||
bitflags! {
|
||||
pub struct ProgramBuilderFlags: u8 {
|
||||
const CaptureChanges = 0x01; /* emit plans with capture changes instructurs for INSERT/DELETE/UPDATE operations */
|
||||
const CaptureDataChanges = 0x01; /* emit plans with capture data changes instructions for INSERT/DELETE/UPDATE statements */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1766,7 +1766,7 @@ pub enum PragmaName {
|
||||
/// trigger a checkpoint to run on database(s) if WAL is enabled
|
||||
WalCheckpoint,
|
||||
/// enable capture-changes logic for the connection
|
||||
CaptureChanges,
|
||||
CaptureDataChanges,
|
||||
}
|
||||
|
||||
/// `CREATE TRIGGER` time
|
||||
|
||||
Reference in New Issue
Block a user