vdbe: modified the Null instruction

modified the Null instruction to more closely match SQLite semantics. Allows passing in a second register and all registers from r1..r2 area set to null
This commit is contained in:
Zaid Humayun
2025-02-09 11:16:57 +05:30
parent 97d87955cc
commit fbc8cd7e70
3 changed files with 11 additions and 9 deletions

View File

@@ -224,7 +224,7 @@ fn emit_schema_entry(
if let Some(sql) = sql {
program.emit_string8(sql, sql_reg);
} else {
program.emit_null(sql_reg);
program.emit_null(sql_reg, None);
}
let record_reg = program.alloc_register();
@@ -552,8 +552,8 @@ fn translate_drop_table(
let init_label = program.emit_init();
let start_offset = program.offset();
let null_reg = program.alloc_register(); // r1
program.emit_null(null_reg);
let r1 = program.alloc_register(); // r1
program.emit_null(r1, None);
let tbl_name_reg = program.alloc_register(); // r2
let table_reg = program.emit_string8_new_reg(tbl_name.name.0.clone()); // r3
program.mark_last_insn_constant();
@@ -573,6 +573,7 @@ fn translate_drop_table(
});
program.emit_insn(Insn::OpenWriteAwait {});
// 1. Remove all entries from the schema table related to the table we are dropping, except for triggers
// loop to beginning of schema table
program.emit_insn(Insn::RewindAsync {
cursor_id: sqlite_schema_cursor_id,
@@ -638,6 +639,10 @@ fn translate_drop_table(
is_temp: 0,
});
let r6 = program.alloc_register();
let r7 = program.alloc_register();
program.emit_null(r6, Some(r7));
// end of the program
program.emit_halt();
program.resolve_label(init_label, program.offset());

View File

@@ -233,7 +233,7 @@ fn query_pragma(
// dflt_value
match &column.default {
None => {
program.emit_null(base_reg + 4);
program.emit_null(base_reg + 4, None);
}
Some(expr) => {
program.emit_string8(expr.to_string(), base_reg + 4);

View File

@@ -138,11 +138,8 @@ impl ProgramBuilder {
});
}
pub fn emit_null(&mut self, dest: usize) {
self.emit_insn(Insn::Null {
dest,
dest_end: None,
});
pub fn emit_null(&mut self, dest: usize, dest_end: Option<usize>) {
self.emit_insn(Insn::Null { dest, dest_end });
}
pub fn emit_result_row(&mut self, start_reg: usize, count: usize) {