From 9dc772e9f98dd04c1485af643d5b63474d528621 Mon Sep 17 00:00:00 2001 From: Alex Garcia Date: Tue, 25 Jun 2024 08:54:51 -0700 Subject: [PATCH] format, pragma_table_list -> sqlite_master --- sqlite-vec.c | 18 ++++++++++-------- tests/test-loadable.py | 29 ++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/sqlite-vec.c b/sqlite-vec.c index 9fd07f7..f036e22 100644 --- a/sqlite-vec.c +++ b/sqlite-vec.c @@ -2837,7 +2837,6 @@ struct vec0_vtab { sqlite3_blob *vectorBlobs[VEC0_MAX_VECTOR_COLUMNS]; }; - void vec0_free_resources(vec0_vtab *p) { for (int i = 0; i < p->numVectorColumns; i++) { sqlite3_blob_close(p->vectorBlobs[i]); @@ -3596,34 +3595,37 @@ static int vec0Destroy(sqlite3_vtab *pVtab) { // TODO evidence-of here - zSql = sqlite3_mprintf("DROP TABLE " VEC0_SHADOW_CHUNKS_NAME, p->schemaName, p->tableName); + zSql = sqlite3_mprintf("DROP TABLE " VEC0_SHADOW_CHUNKS_NAME, p->schemaName, + p->tableName); rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0); sqlite3_free((void *)zSql); - if((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { + if ((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { rc = SQLITE_ERROR; goto done; } - zSql = sqlite3_mprintf("DROP TABLE " VEC0_SHADOW_ROWIDS_NAME, p->schemaName, p->tableName); + zSql = sqlite3_mprintf("DROP TABLE " VEC0_SHADOW_ROWIDS_NAME, p->schemaName, + p->tableName); rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0); sqlite3_free((void *)zSql); - if((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { + if ((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { rc = SQLITE_ERROR; goto done; } for (int i = 0; i < p->numVectorColumns; i++) { - zSql = sqlite3_mprintf("DROP TABLE \"%w\".\"%w\"" , p->schemaName, p->shadowVectorChunksNames[i]); + zSql = sqlite3_mprintf("DROP TABLE \"%w\".\"%w\"", p->schemaName, + p->shadowVectorChunksNames[i]); rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0); sqlite3_free((void *)zSql); - if((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { + if ((rc != SQLITE_OK) || (sqlite3_step(stmt) != SQLITE_DONE)) { rc = SQLITE_ERROR; goto done; } } rc = SQLITE_OK; - done: +done: sqlite3_free(p); sqlite3_finalize(stmt); return rc; diff --git a/tests/test-loadable.py b/tests/test-loadable.py index dad32b0..b18f679 100644 --- a/tests/test-loadable.py +++ b/tests/test-loadable.py @@ -748,18 +748,29 @@ def test_vec0_update_insert_errors2(): def test_vec0_drops(): db = connect(EXT_PATH) - db.execute("create virtual table t1 using vec0(aaa float[4], bbb float[4], chunk_size=8)") - assert [row['name'] for row in execute_all(db, "select name from pragma_table_list where name like 't1%' order by 1")] == [ - 't1', - 't1_chunks', - 't1_rowids', - 't1_vector_chunks00', - 't1_vector_chunks01', + db.execute( + "create virtual table t1 using vec0(aaa float[4], bbb float[4], chunk_size=8)" + ) + assert [ + row["name"] + for row in execute_all( + db, "select name from sqlite_master where name like 't1%' order by 1" + ) + ] == [ + "t1", + "t1_chunks", + "t1_rowids", + "t1_vector_chunks00", + "t1_vector_chunks01", ] db.execute("drop table t1") - assert [row['name'] for row in execute_all(db, "select name from pragma_table_list where name like 't1%' order by 1")] == [ + assert [ + row["name"] + for row in execute_all( + db, "select name from sqlite_master where name like 't1%' order by 1" + ) + ] == [] - ] def test_vec0_update_deletes(): db = connect(EXT_PATH)