Support DROP INDEX

This commit adds suport for DROP INDEX.
Bytecode produced by this commit differs from SQLITE's bytecode, main
reason we don't do autovacuum or repacking of pages like SQLITE does.
This commit is contained in:
Anton Harniakou 2025-04-25 21:41:02 +03:00
parent 7137f4ab3b
commit 6c8eef2fac
6 changed files with 225 additions and 10 deletions

View file

@ -189,6 +189,24 @@ pub fn op_divide(
Ok(InsnFunctionStepResult::Step)
}
pub fn op_drop_index(
program: &Program,
state: &mut ProgramState,
insn: &Insn,
pager: &Rc<Pager>,
mv_store: Option<&Rc<MvStore>>,
) -> Result<InsnFunctionStepResult> {
let Insn::DropIndex { index, db } = insn else {
unreachable!("unexpected Insn {:?}", insn)
};
if let Some(conn) = program.connection.upgrade() {
let mut schema = conn.schema.write();
schema.remove_index(&index);
}
state.pc += 1;
Ok(InsnFunctionStepResult::Step)
}
pub fn op_remainder(
program: &Program,
state: &mut ProgramState,
@ -4157,13 +4175,7 @@ pub fn op_drop_table(
pager: &Rc<Pager>,
mv_store: Option<&Rc<MvStore>>,
) -> Result<InsnFunctionStepResult> {
let Insn::DropTable {
db,
_p2,
_p3,
table_name,
} = insn
else {
let Insn::DropTable { db, table_name, .. } = insn else {
unreachable!("unexpected Insn {:?}", insn)
};
if *db > 0 {