mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-20 07:25:14 +01:00
modified OpenWrite to include index or table name in explain
This commit is contained in:
@@ -485,6 +485,7 @@ fn emit_delete_insns(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: index_cursor_id,
|
||||
root_page: RegisterOrLiteral::Literal(index.root_page),
|
||||
name: index.name.clone(),
|
||||
});
|
||||
let num_regs = index.columns.len() + 1;
|
||||
let start_reg = program.alloc_registers(num_regs);
|
||||
|
||||
@@ -100,6 +100,7 @@ pub fn translate_create_index(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: sqlite_schema_cursor_id,
|
||||
root_page: RegisterOrLiteral::Literal(sqlite_table.root_page),
|
||||
name: sqlite_table.name.clone(),
|
||||
});
|
||||
let sql = create_idx_stmt_to_sql(&tbl_name, &idx_name, unique_if_not_exists, &columns);
|
||||
emit_schema_entry(
|
||||
@@ -181,6 +182,7 @@ pub fn translate_create_index(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: btree_cursor_id,
|
||||
root_page: RegisterOrLiteral::Register(root_page_reg),
|
||||
name: idx_name.clone()
|
||||
});
|
||||
|
||||
let sorted_loop_start = program.allocate_label();
|
||||
|
||||
@@ -177,6 +177,7 @@ pub fn translate_insert(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id,
|
||||
root_page: RegisterOrLiteral::Literal(root_page),
|
||||
name: table_name.0.clone(),
|
||||
});
|
||||
|
||||
// Main loop
|
||||
@@ -192,6 +193,7 @@ pub fn translate_insert(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id,
|
||||
root_page: RegisterOrLiteral::Literal(root_page),
|
||||
name: table_name.0.clone(),
|
||||
});
|
||||
|
||||
populate_column_registers(
|
||||
@@ -209,6 +211,7 @@ pub fn translate_insert(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: idx_cursor.2,
|
||||
root_page: idx_cursor.1.into(),
|
||||
name: idx_cursor.0.clone(),
|
||||
});
|
||||
}
|
||||
// Common record insertion logic for both single and multiple rows
|
||||
|
||||
@@ -110,6 +110,7 @@ pub fn init_loop(
|
||||
cursor_id: table_cursor_id
|
||||
.expect("table cursor is always opened in OperationMode::DELETE"),
|
||||
root_page: root_page.into(),
|
||||
name: btree.name.clone(),
|
||||
});
|
||||
}
|
||||
(OperationMode::UPDATE, Table::BTree(btree)) => {
|
||||
@@ -118,11 +119,13 @@ pub fn init_loop(
|
||||
cursor_id: table_cursor_id
|
||||
.expect("table cursor is always opened in OperationMode::UPDATE"),
|
||||
root_page: root_page.into(),
|
||||
name: btree.name.clone(),
|
||||
});
|
||||
if let Some(index_cursor_id) = index_cursor_id {
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: index_cursor_id,
|
||||
root_page: index.as_ref().unwrap().root_page.into(),
|
||||
name: index.as_ref().unwrap().name.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -148,6 +151,7 @@ pub fn init_loop(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: table_cursor_id,
|
||||
root_page: table.table.get_root_page().into(),
|
||||
name: table.table.get_name().to_string(),
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
@@ -174,6 +178,7 @@ pub fn init_loop(
|
||||
cursor_id: index_cursor_id
|
||||
.expect("index cursor is always opened in Seek with index"),
|
||||
root_page: index.root_page.into(),
|
||||
name: index.name.clone(),
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -120,6 +120,7 @@ pub fn translate_create_table(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: sqlite_schema_cursor_id,
|
||||
root_page: 1usize.into(),
|
||||
name: tbl_name.name.0.clone()
|
||||
});
|
||||
|
||||
// Add the table entry to sqlite_schema
|
||||
@@ -582,6 +583,7 @@ pub fn translate_create_virtual_table(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: sqlite_schema_cursor_id,
|
||||
root_page: 1usize.into(),
|
||||
name: table_name.clone()
|
||||
});
|
||||
|
||||
let sql = create_vtable_body_to_str(&vtab, vtab_module.clone());
|
||||
@@ -661,6 +663,7 @@ pub fn translate_drop_table(
|
||||
program.emit_insn(Insn::OpenWrite {
|
||||
cursor_id: sqlite_schema_cursor_id,
|
||||
root_page: 1usize.into(),
|
||||
name: tbl_name.name.0.clone()
|
||||
});
|
||||
|
||||
// 1. Remove all entries from the schema table related to the table we are dropping, except for triggers
|
||||
|
||||
@@ -1122,6 +1122,7 @@ pub fn insn_to_str(
|
||||
Insn::OpenWrite {
|
||||
cursor_id,
|
||||
root_page,
|
||||
name,
|
||||
..
|
||||
} => (
|
||||
"OpenWrite",
|
||||
@@ -1133,7 +1134,7 @@ pub fn insn_to_str(
|
||||
0,
|
||||
OwnedValue::build_text(""),
|
||||
0,
|
||||
"".to_string(),
|
||||
format!("root={}; {}", root_page, name),
|
||||
),
|
||||
Insn::Copy {
|
||||
src_reg,
|
||||
|
||||
@@ -708,6 +708,7 @@ pub enum Insn {
|
||||
OpenWrite {
|
||||
cursor_id: CursorID,
|
||||
root_page: RegisterOrLiteral<PageIdx>,
|
||||
name: String,
|
||||
},
|
||||
|
||||
Copy {
|
||||
|
||||
Reference in New Issue
Block a user