cql3: Fully explain statement_restrictions members

Nail down the assumptions before making futher use of these variables.

Signed-off-by: Dejan Mircevski <dejan@scylladb.com>
This commit is contained in:
Dejan Mircevski
2021-06-29 20:38:29 +02:00
parent 28e92dfa4c
commit 75f4325ee4
2 changed files with 27 additions and 16 deletions

View File

@@ -221,20 +221,9 @@ static std::vector<expr::expression> extract_partition_range(
return {};
}
/// Extracts where_clause atoms with clustering-column LHS and copies them to a vector such that:
/// 1. all elements must be simultaneously satisfied (as restrictions) for where_clause to be satisfied
/// 2. each element is an atom or a conjunction of atoms
/// 3. either all atoms (across all elements) are multi-column or they are all single-column
/// 4. if single-column, then:
/// 4.1 all atoms from an element have the same LHS, which we call the element's LHS
/// 4.2 each element's LHS is different from any other element's LHS
/// 4.3 the list of each element's LHS, in order, forms a clustering-key prefix
/// 4.4 elements other than the last have only EQ or IN atoms
/// 4.5 the last element has only EQ, IN, or is_slice() atoms
///
/// These elements define the boundaries of any clustering slice that can possibly meet where_clause.
///
/// This vector can be calculated before binding expression markers, since LHS and operator are always known.
/// Extracts where_clause atoms with clustering-column LHS and copies them to a vector. These elements define the
/// boundaries of any clustering slice that can possibly meet where_clause. This vector can be calculated before
/// binding expression markers, since LHS and operator are always known.
static std::vector<expr::expression> extract_clustering_prefix_restrictions(
const expr::expression& where_clause, schema_ptr schema) {
using namespace expr;

View File

@@ -105,8 +105,30 @@ private:
bool _has_queriable_regular_index = false, _has_queriable_pk_index = false, _has_queriable_ck_index = false;
std::optional<expr::expression> _where; ///< The entire WHERE clause.
std::vector<expr::expression> _clustering_prefix_restrictions; ///< Parts of _where defining the clustering slice.
std::vector<expr::expression> _partition_range_restrictions; ///< Parts of _where defining the partition range.
/// Parts of _where defining the clustering slice.
///
/// Meets all of the following conditions:
/// 1. all elements must be simultaneously satisfied (as restrictions) for _where to be satisfied
/// 2. each element is an atom or a conjunction of atoms
/// 3. either all atoms (across all elements) are multi-column or they are all single-column
/// 4. if single-column, then:
/// 4.1 all atoms from an element have the same LHS, which we call the element's LHS
/// 4.2 each element's LHS is different from any other element's LHS
/// 4.3 the list of each element's LHS, in order, forms a clustering-key prefix
/// 4.4 elements other than the last have only EQ or IN atoms
/// 4.5 the last element has only EQ, IN, or is_slice() atoms
/// 5. if multi-column, then each element is a binary_operator
std::vector<expr::expression> _clustering_prefix_restrictions;
/// Parts of _where defining the partition range.
///
/// If the partition range is dictated by token restrictions, this is a single element that holds all the
/// binary_operators on token. If single-column restrictions define the partition range, each element holds
/// restrictions for one partition column. Each partition column has a corresponding element, but the elements
/// are in arbitrary order.
std::vector<expr::expression> _partition_range_restrictions;
bool _partition_range_is_simple; ///< False iff _partition_range_restrictions imply a Cartesian product.
public: