diff --git a/core/lib.rs b/core/lib.rs index b9f0a25d1..00889db98 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -316,10 +316,8 @@ impl Connection { pub(crate) fn run_cmd(self: &Rc, cmd: Cmd) -> Result> { let db = self.db.clone(); let syms: &SymbolTable = &db.syms.borrow(); - println!("the command {:?}", cmd); match cmd { Cmd::Stmt(stmt) => { - println!("AST: {:?}", stmt); let program = Rc::new(translate::translate( &self.schema.borrow(), stmt, @@ -329,7 +327,6 @@ impl Connection { syms, QueryMode::Normal, )?); - println!("the generated program {:?}", program); let stmt = Statement::new(program, self.pager.clone()); Ok(Some(stmt)) } @@ -370,13 +367,11 @@ impl Connection { } pub fn execute(self: &Rc, sql: impl AsRef) -> Result<()> { - println!("running execute"); let sql = sql.as_ref(); let db = &self.db; let syms: &SymbolTable = &db.syms.borrow(); let mut parser = Parser::new(sql.as_bytes()); let cmd = parser.next()?; - println!("the command {:?}", cmd); if let Some(cmd) = cmd { match cmd { Cmd::Explain(stmt) => { diff --git a/core/vdbe/explain.rs b/core/vdbe/explain.rs index be0e4f92a..98dd5b80e 100644 --- a/core/vdbe/explain.rs +++ b/core/vdbe/explain.rs @@ -1101,6 +1101,22 @@ pub fn insn_to_str( 0, format!("r[{}]=root iDb={} flags={}", root, db, flags), ), + Insn::Destroy { + root, + former_root_reg, + is_temp, + } => ( + "Destroy", + *root as i32, + *former_root_reg as i32, + *is_temp as i32, + OwnedValue::build_text(Rc::new("".to_string())), + 0, + format!( + "root iDb={} former_root={} is_temp={}", + root, former_root_reg, is_temp + ), + ), Insn::DropTable { db, root } => ( "DropTable", *db as i32, diff --git a/core/vdbe/insn.rs b/core/vdbe/insn.rs index 897842d4d..2402d17ed 100644 --- a/core/vdbe/insn.rs +++ b/core/vdbe/insn.rs @@ -590,6 +590,16 @@ pub enum Insn { flags: usize, }, + /// Deletes an entire database table or index whose root page in the database file is given by P1. + Destroy { + /// The root page of the table/index to destroy + root: usize, + /// Register to store the former value of any moved root page (for AUTOVACUUM) + former_root_reg: usize, + /// Whether this is a temporary table (1) or main database table (0) + is_temp: usize, + }, + // Drop a table DropTable { // The database within which this b-tree needs to be dropped (P1). diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index b28a1faf9..f18b16f29 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -2688,14 +2688,24 @@ impl Program { state.registers[*root] = OwnedValue::Integer(root_page as i64); state.pc += 1; } - Insn::DropTable { db, root } => { - if *db > 0 { - todo!("temp databases not implemented yet"); + Insn::Destroy { + root, + former_root_reg: _, + is_temp, + } => { + if *is_temp == 1 { + todo!("temp databases not implemented yet."); } let mut cursor = Box::new(BTreeCursor::new(pager.clone(), *root)); cursor.btree_drop()?; state.pc += 1; } + Insn::DropTable { db, root: _ } => { + if *db > 0 { + todo!("temp databases not implemented yet"); + } + // TODO (Zaid): implement the functionality to clean up in-memory structures + } Insn::Close { cursor_id } => { let mut cursors = state.cursors.borrow_mut(); cursors.get_mut(*cursor_id).unwrap().take();