mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-31 13:54:27 +01:00
Do not count ephemeral table INSERTs as changes
This commit is contained in:
@@ -133,7 +133,9 @@ pub fn emit_result_row_and_limit(
|
||||
key_reg: result_columns_start_reg + (plan.result_columns.len() - 1), // Rowid reg is the last register
|
||||
record_reg,
|
||||
// since we are not doing an Insn::NewRowid or an Insn::NotExists here, we need to seek to ensure the insertion happens in the correct place.
|
||||
flag: InsertFlags::new().require_seek(),
|
||||
flag: InsertFlags::new()
|
||||
.require_seek()
|
||||
.is_ephemeral_table_insert(),
|
||||
table_name: table.name.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5892,7 +5892,10 @@ pub fn op_insert(
|
||||
let cursor = cursor.as_btree_mut();
|
||||
cursor.root_page()
|
||||
};
|
||||
if root_page != 1 && table_name != "sqlite_sequence" {
|
||||
if root_page != 1
|
||||
&& table_name != "sqlite_sequence"
|
||||
&& !flag.has(InsertFlags::EPHEMERAL_TABLE_INSERT)
|
||||
{
|
||||
state.op_insert_state.sub_state = OpInsertSubState::UpdateLastRowid;
|
||||
} else {
|
||||
let schema = program.connection.schema.read();
|
||||
|
||||
@@ -112,6 +112,7 @@ pub struct InsertFlags(pub u8);
|
||||
impl InsertFlags {
|
||||
pub const UPDATE_ROWID_CHANGE: u8 = 0x01; // Flag indicating this is part of an UPDATE statement where the row's rowid is changed
|
||||
pub const REQUIRE_SEEK: u8 = 0x02; // Flag indicating that a seek is required to insert the row
|
||||
pub const EPHEMERAL_TABLE_INSERT: u8 = 0x04; // Flag indicating that this is an insert into an ephemeral table
|
||||
|
||||
pub fn new() -> Self {
|
||||
InsertFlags(0)
|
||||
@@ -130,6 +131,11 @@ impl InsertFlags {
|
||||
self.0 |= InsertFlags::UPDATE_ROWID_CHANGE;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_ephemeral_table_insert(mut self) -> Self {
|
||||
self.0 |= InsertFlags::EPHEMERAL_TABLE_INSERT;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user