A lean index carries no node_vectors table at all. That is an empty * semantic universe, not a scan failure, and callers must be able to tell * the two apart — so probe the schema before preparing the scan. Returns * CBM_STORE_OK (present), CBM_STORE_NOT_FOUND (absent) or CBM_STORE_ERR. */
| 12284 | * the two apart — so probe the schema before preparing the scan. Returns |
| 12285 | * CBM_STORE_OK (present), CBM_STORE_NOT_FOUND (absent) or CBM_STORE_ERR. */ |
| 12286 | static int vs_probe_node_vectors_table(cbm_store_t *s) { |
| 12287 | sqlite3_stmt *probe = NULL; |
| 12288 | const char *sql = |
| 12289 | "SELECT 1 FROM sqlite_master WHERE type='table' AND name='node_vectors' LIMIT 1;"; |
| 12290 | if (sqlite3_prepare_v2(s->db, sql, SQLITE_AUTO_LEN, &probe, NULL) != SQLITE_OK) { |
| 12291 | (void)fprintf(stderr, "vector_search: %s\n", sqlite3_errmsg(s->db)); |
| 12292 | return CBM_STORE_ERR; |
| 12293 | } |
| 12294 | int step_rc = sqlite3_step(probe); |
| 12295 | sqlite3_finalize(probe); |
| 12296 | if (step_rc == SQLITE_ROW) { |
| 12297 | return CBM_STORE_OK; |
| 12298 | } |
| 12299 | if (step_rc == SQLITE_DONE) { |
| 12300 | return CBM_STORE_NOT_FOUND; |
| 12301 | } |
| 12302 | (void)fprintf(stderr, "vector_search: %s\n", sqlite3_errmsg(s->db)); |
| 12303 | return CBM_STORE_ERR; |
| 12304 | } |
| 12305 | |
| 12306 | static int vs_ranked_result_cmp(const void *lhs, const void *rhs) { |
| 12307 | const cbm_vector_result_t *a = lhs; |
no outgoing calls
no test coverage detected