mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 09:14:24 +01:00
core: SELECT <string> support
This commit is contained in:
@@ -193,7 +193,14 @@ fn translate_expr(
|
||||
});
|
||||
dest
|
||||
}
|
||||
Literal::String(_) => todo!(),
|
||||
Literal::String(s) => {
|
||||
let dest = program.alloc_register();
|
||||
program.emit_insn(Insn::String8 {
|
||||
value: s.to_string(),
|
||||
dest,
|
||||
});
|
||||
dest
|
||||
}
|
||||
Literal::Blob(_) => todo!(),
|
||||
Literal::Keyword(_) => todo!(),
|
||||
Literal::Null => todo!(),
|
||||
|
||||
11
core/vdbe.rs
11
core/vdbe.rs
@@ -80,6 +80,12 @@ pub enum Insn {
|
||||
dest: usize,
|
||||
},
|
||||
|
||||
// Write a string value into a register.
|
||||
String8 {
|
||||
value: String,
|
||||
dest: usize,
|
||||
},
|
||||
|
||||
// Read the rowid of the current row.
|
||||
RowId {
|
||||
cursor_id: CursorID,
|
||||
@@ -307,6 +313,10 @@ impl Program {
|
||||
state.registers[*dest] = OwnedValue::Integer(*value);
|
||||
state.pc += 1;
|
||||
}
|
||||
Insn::String8 { value, dest } => {
|
||||
state.registers[*dest] = OwnedValue::Text(Rc::new(value.into()));
|
||||
state.pc += 1;
|
||||
}
|
||||
Insn::RowId { cursor_id, dest } => {
|
||||
let cursor = cursors.get_mut(cursor_id).unwrap();
|
||||
if let Some(ref rowid) = *cursor.rowid()? {
|
||||
@@ -417,6 +427,7 @@ fn insn_to_str(addr: usize, insn: &Insn) -> String {
|
||||
Insn::Integer { value, dest } => {
|
||||
("Integer", *dest, *value as usize, 0, "", 0, "".to_string())
|
||||
}
|
||||
Insn::String8 { value, dest } => ("String8", *dest, 0, 0, "", 0, "".to_string()),
|
||||
Insn::RowId { cursor_id, dest } => ("RowId", *cursor_id, *dest, 0, "", 0, "".to_string()),
|
||||
Insn::DecrJumpZero { reg, target_pc } => {
|
||||
("DecrJumpZero", *reg, *target_pc, 0, "", 0, "".to_string())
|
||||
|
||||
Reference in New Issue
Block a user