mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-11 03:04:22 +01:00
DropTable: implementation complete
added helper methods to Schema to remove table and indices from in-memory structures completed the implementation for DropTable using that
This commit is contained in:
@@ -30,6 +30,11 @@ impl Schema {
|
||||
self.tables.insert(name, table);
|
||||
}
|
||||
|
||||
pub fn remove_table(&mut self, table_name: &str) {
|
||||
let name = normalize_ident(table_name);
|
||||
self.tables.remove(&name);
|
||||
}
|
||||
|
||||
pub fn get_table(&self, name: &str) -> Option<Rc<BTreeTable>> {
|
||||
let name = normalize_ident(name);
|
||||
self.tables.get(&name).cloned()
|
||||
@@ -42,6 +47,11 @@ impl Schema {
|
||||
.or_default()
|
||||
.push(index.clone())
|
||||
}
|
||||
|
||||
pub fn remove_indices_for_table(&mut self, table_name: &str) {
|
||||
let name = normalize_ident(table_name);
|
||||
self.indexes.remove(&name);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -2709,7 +2709,12 @@ impl Program {
|
||||
if *db > 0 {
|
||||
todo!("temp databases not implemented yet");
|
||||
}
|
||||
// TODO (Zaid): implement the functionality to clean up in-memory structures for table_name
|
||||
if let Some(conn) = self.connection.upgrade() {
|
||||
let mut schema = RefCell::borrow_mut(&conn.schema);
|
||||
schema.remove_indices_for_table(table_name);
|
||||
schema.remove_table(table_name);
|
||||
}
|
||||
state.pc += 1;
|
||||
}
|
||||
Insn::Close { cursor_id } => {
|
||||
let mut cursors = state.cursors.borrow_mut();
|
||||
|
||||
Reference in New Issue
Block a user