cql3: statement_restrictions: fold add_token_partition_key_restriction() into its caller

The goal is to simplify flow-control where the order in which
variables are updated depends on their location in the source.
With functions, this is difficult.
This commit is contained in:
Avi Kivity
2024-12-06 20:55:12 +02:00
parent be3239fc58
commit 24cd98e454
2 changed files with 11 additions and 16 deletions

View File

@@ -1260,7 +1260,17 @@ statement_restrictions::statement_restrictions(private_tag,
}
} else if (has_partition_token(restr, *_schema)) {
// Token always restricts the partition key
add_token_partition_key_restriction(restr);
if (!partition_key_restrictions_is_empty() && !has_token_restrictions()) {
throw exceptions::invalid_request_exception(
seastar::format("Columns \"{}\" cannot be restricted by both a normal relation and a token relation",
fmt::join(expr::get_sorted_column_defs(_partition_key_restrictions) |
std::views::transform([](auto* p) {
return maybe_column_definition{p};
}),
", ")));
}
_partition_key_restrictions = expr::make_conjunction(_partition_key_restrictions, restr);
} else if (is_single_column_restriction(restr)) {
const column_definition* def = get_the_only_column(restr).col;
if (def->is_partition_key()) {
@@ -1673,20 +1683,6 @@ void statement_restrictions::add_single_column_parition_key_restriction(const ex
_partition_range_is_simple &= !find(restr, expr::oper_t::IN);
}
void statement_restrictions::add_token_partition_key_restriction(const expr::binary_operator& restr) {
if (!partition_key_restrictions_is_empty() && !has_token_restrictions()) {
throw exceptions::invalid_request_exception(
seastar::format("Columns \"{}\" cannot be restricted by both a normal relation and a token relation",
fmt::join(expr::get_sorted_column_defs(_partition_key_restrictions) |
std::views::transform([](auto* p) {
return maybe_column_definition{p};
}),
", ")));
}
_partition_key_restrictions = expr::make_conjunction(_partition_key_restrictions, restr);
}
void statement_restrictions::add_single_column_clustering_key_restriction(const expr::binary_operator& restr, schema_ptr schema, bool allow_filtering) {
if (find_binop(_clustering_columns_restrictions, [] (const expr::binary_operator& b) {
return expr::is<expr::tuple_constructor>(b.lhs);

View File

@@ -374,7 +374,6 @@ public:
private:
std::pair<std::optional<secondary_index::index>, expr::expression> do_find_idx(const secondary_index::secondary_index_manager& sim) const;
void add_single_column_parition_key_restriction(const expr::binary_operator& restr, schema_ptr schema, bool allow_filtering, bool for_view);
void add_token_partition_key_restriction(const expr::binary_operator& restr);
void add_single_column_clustering_key_restriction(const expr::binary_operator& restr, schema_ptr schema, bool allow_filtering);
void add_single_column_nonprimary_key_restriction(const expr::binary_operator& restr);