From 22fd3e9781fbec5433189ada5bd4e0fa78d73cb7 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 3 Apr 2025 15:22:09 -0400 Subject: [PATCH 1/3] Fix cli tests --- testing/cli_tests/extensions.py | 6 ++---- testing/cli_tests/test_limbo_cli.py | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/testing/cli_tests/extensions.py b/testing/cli_tests/extensions.py index cb73aa760..058fe2e6b 100755 --- a/testing/cli_tests/extensions.py +++ b/testing/cli_tests/extensions.py @@ -338,16 +338,14 @@ def test_series(): def test_kv(): ext_path = "target/debug/liblimbo_ext_tests" - limbo = TestLimboShell() + limbo = TestLimboShell("") 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');", diff --git a/testing/cli_tests/test_limbo_cli.py b/testing/cli_tests/test_limbo_cli.py index 10e87869d..8b6a61375 100755 --- a/testing/cli_tests/test_limbo_cli.py +++ b/testing/cli_tests/test_limbo_cli.py @@ -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), From ae2be302047268852ffa6c59f7a1f39e5b4ab67a Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 3 Apr 2025 20:22:14 -0400 Subject: [PATCH 2/3] Move init label to proper place in create vtab translation --- core/translate/schema.rs | 5 ++--- core/util.rs | 2 +- core/vdbe/execute.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/translate/schema.rs b/core/translate/schema.rs index a887bdef8..29cf29644 100644 --- a/core/translate/schema.rs +++ b/core/translate/schema.rs @@ -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); diff --git a/core/util.rs b/core/util.rs index 13b53bcb3..f17699233 100644 --- a/core/util.rs +++ b/core/util.rs @@ -58,7 +58,7 @@ pub fn parse_schema_rows( "table" => { let root_page: i64 = row.get::(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); diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 31a64d491..3c511a0db 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -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(); From 97c68f905a4368f75f182786315ece5b2c54ed15 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 3 Apr 2025 20:22:47 -0400 Subject: [PATCH 3/3] Move test back to original setup to ensure issue is solved --- testing/cli_tests/extensions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/cli_tests/extensions.py b/testing/cli_tests/extensions.py index 058fe2e6b..d898908f9 100755 --- a/testing/cli_tests/extensions.py +++ b/testing/cli_tests/extensions.py @@ -338,7 +338,10 @@ def test_series(): def test_kv(): ext_path = "target/debug/liblimbo_ext_tests" - limbo = TestLimboShell("") + 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,