Ensure virtual table name uniqueness

This commit is contained in:
Piotr Rzysko
2025-05-11 10:43:26 +02:00
parent 14ef25ebb8
commit fdffbc9534
2 changed files with 47 additions and 13 deletions

View File

@@ -581,6 +581,36 @@ def test_sqlite_vfs_compat():
sqlite.quit()
def test_create_virtual_table():
ext_path = "target/debug/liblimbo_ext_tests"
limbo = TestLimboShell()
limbo.execute_dot(f".load {ext_path}")
limbo.debug_print("CREATE VIRTUAL TABLE t1 USING kv_store;")
limbo.run_test_fn(
"CREATE VIRTUAL TABLE t1 USING kv_store;",
lambda res: "× Parse error: Table t1 already exists" == res,
"create virtual table fails if virtual table with the same name already exists",
)
limbo.debug_print("CREATE TABLE t2 (col INTEGER);")
limbo.run_test_fn(
"CREATE VIRTUAL TABLE t2 USING kv_store;",
lambda res: "× Parse error: Table t2 already exists" == res,
"create virtual table fails if regular table with the same name already exists",
)
limbo.debug_print("CREATE VIRTUAL TABLE t3 USING kv_store;")
limbo.run_test_fn(
"CREATE TABLE t3 (col INTEGER);",
lambda res: "× Parse error: Table t3 already exists" == res,
"create table fails if virtual table with the same name already exists",
)
limbo.quit()
def cleanup():
if os.path.exists("testing/vfs.db"):
os.remove("testing/vfs.db")
@@ -600,6 +630,7 @@ def main():
test_sqlite_vfs_compat()
test_kv()
test_drop_virtual_table()
test_create_virtual_table()
except Exception as e:
console.error(f"Test FAILED: {e}")
cleanup()