From 240d9be5e24448586db43fef33d9c8b587b4f706 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 12 May 2026 19:07:21 +0300 Subject: [PATCH] cql3: statement_restrictions: set op on all binary-operator-derived predicates The to_predicates() function had fallthrough paths for operators like LIKE and NOT_IN that created predicates without setting the op field. This meant predicate-based checks like 'p.op && needs_filtering(*p.op)' would miss these operators. Fix by inlining the predicate construction at the fallthrough points (instead of using cannot_solve_on_column) and setting .op = oper.op. This ensures all predicates derived from binary operators carry their operator type, enabling reliable predicate-based analysis. The cannot_solve_on_column helper is now unused and removed. --- cql3/restrictions/statement_restrictions.cc | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index ebb545483f..9c7e6bf59d 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -302,13 +302,6 @@ to_predicates( .on = on_row{}, }); }; - static auto cannot_solve_on_column = [] (const expression& e, const column_definition* cdef) -> std::vector { - return to_vector(predicate{ - .solve_for = nullptr, - .filter = e, - .on = on_column{cdef}, - }); - }; return expr::visit(overloaded_functor{ [] (const constant& constant_val) -> std::vector { std::optional bool_val = get_bool_value(constant_val); @@ -402,7 +395,12 @@ to_predicates( .op = oper.op, }); } - return cannot_solve_on_column(oper, col.col); + return to_vector(predicate{ + .solve_for = nullptr, + .filter = oper, + .on = on_column{col.col}, + .op = oper.op, + }); }, [&] (const subscript& s) -> std::vector { const column_value& col = get_subscripted_column(s); @@ -433,7 +431,13 @@ to_predicates( .is_subscript = true, }); } - return cannot_solve_on_column(oper, col.col); + return to_vector(predicate{ + .solve_for = nullptr, + .filter = oper, + .on = on_column{col.col}, + .op = oper.op, + .is_subscript = true, + }); }, [&] (const tuple_constructor& tuple) -> std::vector { auto columns = tuple.elements