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

Function where_add_like_hints

src/store/store.c:2476–2495  ·  view source on GitHub ↗

Prepend LIKE pre-filter conditions for literal segments of a regex pattern. * The idx_nodes_name index satisfies LIKE '%literal%', cutting the rows that * reach the (more expensive) iregexp call to only those containing the literal. * cbm_extract_like_hints bails on alternation, so no false negatives. */

Source from the content-addressed store, hash-verified

2474 * reach the (more expensive) iregexp call to only those containing the literal.
2475 * cbm_extract_like_hints bails on alternation, so no false negatives. */
2476static void where_add_like_hints(const char *column, const char *pattern, char *where, int where_sz,
2477 int *wlen, int *nparams, search_bind_t *binds, int *bind_idx,
2478 search_like_pool_t *pool) {
2479 char *hints[ST_LIKE_HINT_MAX];
2480 int nhints = cbm_extract_like_hints(pattern, hints, ST_LIKE_HINT_MAX);
2481 char bind_buf[CBM_SZ_64];
2482 for (int i = 0; i < nhints; i++) {
2483 char *lp = make_like_hint(hints[i]);
2484 free(hints[i]);
2485 if (!lp)
2486 continue;
2487 int pool_was_full = (pool->count >= ST_LIKE_POOL_MAX);
2488 like_pool_add(pool, lp);
2489 if (pool_was_full)
2490 continue; /* lp was freed — skip bind */
2491 snprintf(bind_buf, sizeof(bind_buf), "%s LIKE ?%d", column, *bind_idx + SKIP_ONE);
2492 *wlen = where_append(where, where_sz, *wlen, nparams, bind_buf);
2493 where_bind_text(binds, bind_idx, lp);
2494 }
2495}
2496
2497/* Build basic WHERE clauses: project, label, name, file, qn patterns. */
2498static int search_where_basic(const cbm_search_params_t *params, char *where, int where_sz,

Callers 1

search_where_basicFunction · 0.85

Calls 5

cbm_extract_like_hintsFunction · 0.85
make_like_hintFunction · 0.85
like_pool_addFunction · 0.85
where_appendFunction · 0.85
where_bind_textFunction · 0.85

Tested by

no test coverage detected