mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-29 12:47:02 +00:00
This PR implements two things: * Getting the value of a conjunction of elements separated by `AND` using `expr::evaluate` * Preparing conjunctions using `prepare_expression` --- `NULL` is treated as an "unkown value" - maybe `true` maybe `false`. `TRUE AND NULL` evaluates to `NULL` because it might be `true` but also might be `false`. `FALSE AND NULL` evaluates to `FALSE` because no matter what value `NULL` acts as, the result will still be `FALSE`. Unset and empty values are not allowed. Usually in CQL the rule is that when `NULL` occurs in an operation the whole expression becomes `NULL`, but here we decided to deviate from this behavior. Treating `NULL` as an "unkown value" is the standard SQL way of handing `NULLs` in conjunctions. It works this way in MySQL and Postgres so we do it this way as well. The evaluation short-circuits. Once `FALSE` is encountered the function returns `FALSE` immediately without evaluating any further elements. It works this way in Postgres as well, for example: `SELECT true AND NULL AND 1/0 = 0` will throw a division by zero error, but `SELECT false AND 1/0 = 0` will successfully evaluate to `FALSE`. Closes #12300 * github.com:scylladb/scylladb: expr_test: add unit tests for prepare_expression(conjunction) cql3: expr: make it possible to prepare conjunctions expr_test: add tests for evaluate(conjunction) cql3: expr: make it possible to evaluate conjunctions