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. */
| 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. */ |
| 2476 | static 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. */ |
| 2498 | static int search_where_basic(const cbm_search_params_t *params, char *where, int where_sz, |
no test coverage detected