Evaluate WHERE clause — uses expression tree if available, falls back to legacy */
| 2850 | |
| 2851 | /* Evaluate WHERE clause — uses expression tree if available, falls back to legacy */ |
| 2852 | static bool eval_where(const cbm_where_clause_t *w, binding_t *b) { |
| 2853 | if (!w) { |
| 2854 | return true; |
| 2855 | } |
| 2856 | if (w->root) { |
| 2857 | return eval_expr(w->root, b); |
| 2858 | } |
| 2859 | |
| 2860 | /* Legacy flat evaluation */ |
| 2861 | if (w->count == 0) { |
| 2862 | return true; |
| 2863 | } |
| 2864 | bool is_and = (w->op && strcmp(w->op, "AND") == 0) != 0; |
| 2865 | for (int i = 0; i < w->count; i++) { |
| 2866 | bool r = eval_condition(&w->conditions[i], b); |
| 2867 | if (is_and && !r) { |
| 2868 | return false; |
| 2869 | } |
| 2870 | if (!is_and && r) { |
| 2871 | return true; |
| 2872 | } |
| 2873 | } |
| 2874 | return is_and; |
| 2875 | } |
| 2876 | |
| 2877 | /* Three-valued WHERE evaluation for the early (seed-row) pass in |
| 2878 | * execute_single: only the first MATCH alias is bound there, so a leaf on |
no test coverage detected