The project's doc_link_candidates rows (0 without the table); -1 on an * error. */
| 15342 | /* The project's doc_link_candidates rows (0 without the table); -1 on an |
| 15343 | * error. */ |
| 15344 | static 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. */ |
no test coverage detected