Evaluate WHERE clause — uses expression tree if available, falls back to legacy */
| 2722 | |
| 2723 | /* Evaluate WHERE clause — uses expression tree if available, falls back to legacy */ |
| 2724 | static bool eval_where(const cbm_where_clause_t *w, binding_t *b) { |
| 2725 | if (!w) { |
| 2726 | return true; |
| 2727 | } |
| 2728 | if (w->root) { |
| 2729 | return eval_expr(w->root, b); |
| 2730 | } |
| 2731 | |
| 2732 | /* Legacy flat evaluation */ |
| 2733 | if (w->count == 0) { |
| 2734 | return true; |
| 2735 | } |
| 2736 | bool is_and = (w->op && strcmp(w->op, "AND") == 0) != 0; |
| 2737 | for (int i = 0; i < w->count; i++) { |
| 2738 | bool r = eval_condition(&w->conditions[i], b); |
| 2739 | if (is_and && !r) { |
| 2740 | return false; |
| 2741 | } |
| 2742 | if (!is_and && r) { |
| 2743 | return true; |
| 2744 | } |
| 2745 | } |
| 2746 | return is_and; |
| 2747 | } |
| 2748 | |
| 2749 | /* Check if a string value looks like a regex pattern. */ |
| 2750 | static bool looks_like_regex(const char *s) { |
no test coverage detected