mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
format, pragma_table_list -> sqlite_master
This commit is contained in:
parent
feea3bfe43
commit
9dc772e9f9
2 changed files with 30 additions and 17 deletions
18
sqlite-vec.c
18
sqlite-vec.c
|
|
@ -2837,7 +2837,6 @@ struct vec0_vtab {
|
||||||
sqlite3_blob *vectorBlobs[VEC0_MAX_VECTOR_COLUMNS];
|
sqlite3_blob *vectorBlobs[VEC0_MAX_VECTOR_COLUMNS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void vec0_free_resources(vec0_vtab *p) {
|
void vec0_free_resources(vec0_vtab *p) {
|
||||||
for (int i = 0; i < p->numVectorColumns; i++) {
|
for (int i = 0; i < p->numVectorColumns; i++) {
|
||||||
sqlite3_blob_close(p->vectorBlobs[i]);
|
sqlite3_blob_close(p->vectorBlobs[i]);
|
||||||
|
|
@ -3596,34 +3595,37 @@ static int vec0Destroy(sqlite3_vtab *pVtab) {
|
||||||
|
|
||||||
// TODO evidence-of here
|
// 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);
|
rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0);
|
||||||
sqlite3_free((void *)zSql);
|
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;
|
rc = SQLITE_ERROR;
|
||||||
goto done;
|
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);
|
rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0);
|
||||||
sqlite3_free((void *)zSql);
|
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;
|
rc = SQLITE_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < p->numVectorColumns; i++) {
|
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);
|
rc = sqlite3_prepare_v2(p->db, zSql, -1, &stmt, 0);
|
||||||
sqlite3_free((void *)zSql);
|
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;
|
rc = SQLITE_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
done:
|
done:
|
||||||
sqlite3_free(p);
|
sqlite3_free(p);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
||||||
|
|
@ -748,18 +748,29 @@ def test_vec0_update_insert_errors2():
|
||||||
|
|
||||||
def test_vec0_drops():
|
def test_vec0_drops():
|
||||||
db = connect(EXT_PATH)
|
db = connect(EXT_PATH)
|
||||||
db.execute("create virtual table t1 using vec0(aaa float[4], bbb float[4], chunk_size=8)")
|
db.execute(
|
||||||
assert [row['name'] for row in execute_all(db, "select name from pragma_table_list where name like 't1%' order by 1")] == [
|
"create virtual table t1 using vec0(aaa float[4], bbb float[4], chunk_size=8)"
|
||||||
't1',
|
)
|
||||||
't1_chunks',
|
assert [
|
||||||
't1_rowids',
|
row["name"]
|
||||||
't1_vector_chunks00',
|
for row in execute_all(
|
||||||
't1_vector_chunks01',
|
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")
|
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():
|
def test_vec0_update_deletes():
|
||||||
db = connect(EXT_PATH)
|
db = connect(EXT_PATH)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue