mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-06 17:54:20 +01:00
Merge 'Fix virtual table translation issues' from Preston Thorpe
closes #1240 some idiot (read: me) had the init label of `CREATE VIRTUAL TABLE` translation completely in the wrong place 🤔 Closes #1247
This commit is contained in:
@@ -462,7 +462,8 @@ pub fn translate_create_virtual_table(
|
||||
approx_num_insns: 40,
|
||||
approx_num_labels: 2,
|
||||
});
|
||||
|
||||
let init_label = program.emit_init();
|
||||
let start_offset = program.offset();
|
||||
let module_name_reg = program.emit_string8_new_reg(module_name_str.clone());
|
||||
let table_name_reg = program.emit_string8_new_reg(table_name.clone());
|
||||
|
||||
@@ -520,8 +521,6 @@ pub fn translate_create_virtual_table(
|
||||
where_clause: parse_schema_where_clause,
|
||||
});
|
||||
|
||||
let init_label = program.emit_init();
|
||||
let start_offset = program.offset();
|
||||
program.emit_halt();
|
||||
program.resolve_label(init_label, program.offset());
|
||||
program.emit_transaction(true);
|
||||
|
||||
@@ -58,7 +58,7 @@ pub fn parse_schema_rows(
|
||||
"table" => {
|
||||
let root_page: i64 = row.get::<i64>(3)?;
|
||||
let sql: &str = row.get::<&str>(4)?;
|
||||
if root_page == 0 && sql.to_lowercase().contains("virtual") {
|
||||
if root_page == 0 && sql.to_lowercase().contains("create virtual") {
|
||||
let name: &str = row.get::<&str>(1)?;
|
||||
let vtab = syms.vtabs.get(name).unwrap().clone();
|
||||
schema.add_virtual_table(vtab);
|
||||
|
||||
@@ -4110,7 +4110,7 @@ pub fn op_parse_schema(
|
||||
let conn = program.connection.upgrade();
|
||||
let conn = conn.as_ref().unwrap();
|
||||
let stmt = conn.prepare(format!(
|
||||
"SELECT * FROM sqlite_schema WHERE {}",
|
||||
"SELECT * FROM sqlite_schema WHERE {}",
|
||||
where_clause
|
||||
))?;
|
||||
let mut schema = conn.schema.write();
|
||||
|
||||
@@ -339,15 +339,16 @@ def test_series():
|
||||
def test_kv():
|
||||
ext_path = "target/debug/liblimbo_ext_tests"
|
||||
limbo = TestLimboShell()
|
||||
# first, create a normal table to ensure no issues
|
||||
limbo.execute_dot("CREATE TABLE other (a,b,c);")
|
||||
limbo.execute_dot("INSERT INTO other values (23,32,23);")
|
||||
limbo.run_test_fn(
|
||||
"create virtual table t using kv_store;",
|
||||
lambda res: "Virtual table module not found: kv_store" in res,
|
||||
)
|
||||
limbo.execute_dot(f".load {ext_path}")
|
||||
limbo.run_test_fn(
|
||||
limbo.debug_print(
|
||||
"create virtual table t using kv_store;",
|
||||
null,
|
||||
"can create kv_store vtable",
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"insert into t values ('hello', 'world');",
|
||||
|
||||
@@ -111,7 +111,6 @@ class TestLimboShell:
|
||||
if init_commands is None:
|
||||
# Default initialization
|
||||
init_commands = """
|
||||
.open :memory:
|
||||
CREATE TABLE users (id INTEGER PRIMARY KEY, first_name TEXT, last_name TEXT, age INTEGER);
|
||||
CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price INTEGER);
|
||||
INSERT INTO users VALUES (1, 'Alice', 'Smith', 30), (2, 'Bob', 'Johnson', 25),
|
||||
|
||||
Reference in New Issue
Block a user