MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / doccand_rows

Function doccand_rows

tests/test_mcp.c:15344–15372  ·  view source on GitHub ↗

The project's doc_link_candidates rows (0 without the table); -1 on an * error. */

Source from the content-addressed store, hash-verified

15342/* The project's doc_link_candidates rows (0 without the table); -1 on an
15343 * error. */
15344static int doccand_rows(const char *cache) {
15345 char path[CBM_SZ_4K];
15346 if (!doccand_project_db(cache, path, sizeof(path))) {
15347 return -1;
15348 }
15349 cbm_store_t *s = cbm_store_open_path(path);
15350 if (!s) {
15351 return -1;
15352 }
15353 sqlite3 *db = cbm_store_get_db(s);
15354 sqlite3_stmt *st = NULL;
15355 int n = -1;
15356 if (sqlite3_prepare_v2(db,
15357 "SELECT count(*) FROM sqlite_master WHERE type='table' AND "
15358 "name='doc_link_candidates'",
15359 -1, &st, NULL) == SQLITE_OK) {
15360 bool has_table = sqlite3_step(st) == SQLITE_ROW && sqlite3_column_int(st, 0) > 0;
15361 sqlite3_finalize(st);
15362 st = NULL;
15363 n = 0;
15364 if (has_table && sqlite3_prepare_v2(db, "SELECT count(*) FROM doc_link_candidates", -1,
15365 &st, NULL) == SQLITE_OK) {
15366 n = sqlite3_step(st) == SQLITE_ROW ? sqlite3_column_int(st, 0) : -1;
15367 sqlite3_finalize(st);
15368 }
15369 }
15370 cbm_store_close(s);
15371 return n;
15372}
15373
15374/* One fresh full index (the project DB removed first, so no incremental route
15375 * can keep earlier rows); returns the candidate rows, -1 on an index error. */

Callers 1

doccand_indexFunction · 0.85

Calls 4

doccand_project_dbFunction · 0.85
cbm_store_open_pathFunction · 0.85
cbm_store_get_dbFunction · 0.85
cbm_store_closeFunction · 0.85

Tested by

no test coverage detected