Evaluate WHERE clause — uses expression tree if available, falls back to legacy */
| 2498 | |
| 2499 | /* Evaluate WHERE clause — uses expression tree if available, falls back to legacy */ |
| 2500 | static bool eval_where(const cbm_where_clause_t *w, binding_t *b) { |
| 2501 | if (!w) { |
| 2502 | return true; |
| 2503 | } |
| 2504 | if (w->root) { |
| 2505 | return eval_expr(w->root, b); |
| 2506 | } |
| 2507 | |
| 2508 | /* Legacy flat evaluation */ |
| 2509 | if (w->count == 0) { |
| 2510 | return true; |
| 2511 | } |
| 2512 | bool is_and = (w->op && strcmp(w->op, "AND") == 0) != 0; |
| 2513 | for (int i = 0; i < w->count; i++) { |
| 2514 | bool r = eval_condition(&w->conditions[i], b); |
| 2515 | if (is_and && !r) { |
| 2516 | return false; |
| 2517 | } |
| 2518 | if (!is_and && r) { |
| 2519 | return true; |
| 2520 | } |
| 2521 | } |
| 2522 | return is_and; |
| 2523 | } |
| 2524 | |
| 2525 | /* Check if a string value looks like a regex pattern. */ |
| 2526 | static bool looks_like_regex(const char *s) { |
no test coverage detected