mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 14:33:08 +00:00
This PR adds the function: ```c++ constant evaluate(const expression&, const query_options&); ``` which evaluates the given expression to a constant value. It binds all the bound values, calls functions, and reduces the whole expression to just raw bytes and `data_type`, just like `bind()` and `get()` did for `term`. The code is often similar to the original `bind()` implementation in `lists.cc`, `sets.cc`, etc. * For some reason in the original code, when a collection contains `unset_value`, then the whole collection is evaluated to `unset_value`. I'm not sure why this is the case, considering it's impossible to have `unset_value` inside a collection, because we forbid bind markers inside collections. For example here:cc8fc73761/cql3/lists.cc (L134)This seems to have been introduced by Pekka Enberg in50ec81ee67, but he has left the company. I didn't change the behaviour, maybe there is a reason behind it, although maybe it would be better to just throw `invalid_request_exception`. * There was a strange limitation on map key size, it seems incorrect:cc8fc73761/cql3/maps.cc (L150), but I left it in. * When evaluating a `user_type` value, the old code tolerated `unset_value` in a field, but it was later converted to NULL. This means that `unset_value` doesn't work inside a `user_type`, I didn't change it, will do in another PR. * We can't fully get rid of `bind()` yet, because it's used in `prepare_term` to return a `terminal`. It will be removed in the next PR, where we finally get rid of `term`. Closes #9353 * github.com:scylladb/scylla: cql3: types: Optimize abstract_type::contains_collection cql3: expr: Convert evaluate_IN_list to use evaluate(expression) cql3: expr: Use only evaluate(expression) to evaluate term cql3: expr: Implement evaluate(expr::function_call) cql3: expr: Implement evaluate(expr::usertype_constructor) cql3: expr: Implement evaluate(expr::collection_constructor) cql3: expr: Implement evaluate(expr::tuple_constructor) cql3: expr: Implement evaluate(expr::bind_variable) cql3: Add contains_collection/set_or_map to abstract_type cql3: expr: Add evaluate(expression, query_options) cql3: Implement term::to_expression for function_call cql3: Implement term::to_expression for user_type cql3: Implement term::to_expression for collections cql3: Implement term::to_expression for tuples cql3: Implement term::to_expression for marker classes cql3: expr: Add data_type to *_constructor structs cql3: Add term::to_expression method cql3: Reorganize term and expression includes
110 KiB
110 KiB