cql3: Return an expression in get_clustering_columns_restrctions()
get_clustering_columns_restrctions() used to return a shared pointer to the clustering_restrictions class. Now everything is being converted to expression, so it should return an expression as well. Signed-off-by: Jan Ciolek <jan.ciolek@scylladb.com>
This commit is contained in:
@@ -183,8 +183,8 @@ public:
|
||||
return _partition_key_restrictions;
|
||||
}
|
||||
|
||||
::shared_ptr<clustering_key_restrictions> get_clustering_columns_restrictions() const {
|
||||
return _clustering_columns_restrictions;
|
||||
const expr::expression& get_clustering_columns_restrictions() const {
|
||||
return _new_clustering_columns_restrictions;
|
||||
}
|
||||
|
||||
bool has_token_restrictions() const {
|
||||
|
||||
@@ -423,13 +423,13 @@ bool result_set_builder::restrictions_filter::do_filter(const selection& selecti
|
||||
return false;
|
||||
}
|
||||
|
||||
auto clustering_columns_restrictions = _restrictions->get_clustering_columns_restrictions();
|
||||
if (dynamic_pointer_cast<cql3::restrictions::multi_column_restriction>(clustering_columns_restrictions)) {
|
||||
const expr::expression& clustering_columns_restrictions = _restrictions->get_clustering_columns_restrictions();
|
||||
if (expr::contains_multi_column_restriction(clustering_columns_restrictions)) {
|
||||
clustering_key_prefix ckey = clustering_key_prefix::from_exploded(clustering_key);
|
||||
// FIXME: push to upper layer so it happens once per row
|
||||
auto static_and_regular_columns = expr::get_non_pk_values(selection, static_row, row);
|
||||
return expr::is_satisfied_by(
|
||||
clustering_columns_restrictions->expression,
|
||||
clustering_columns_restrictions,
|
||||
expr::evaluation_inputs{
|
||||
.partition_key = &partition_key,
|
||||
.clustering_key = &clustering_key,
|
||||
|
||||
@@ -78,7 +78,7 @@ delete_statement::prepare_internal(data_dictionary::database db, schema_ptr sche
|
||||
}
|
||||
prepare_conditions(db, *schema, ctx, *stmt);
|
||||
stmt->process_where_clause(db, _where_clause, ctx);
|
||||
if (has_slice(stmt->restrictions().get_clustering_columns_restrictions()->expression)) {
|
||||
if (has_slice(stmt->restrictions().get_clustering_columns_restrictions())) {
|
||||
if (!schema->is_compound()) {
|
||||
throw exceptions::invalid_request_exception("Range deletions on \"compact storage\" schemas are not supported");
|
||||
}
|
||||
|
||||
@@ -399,10 +399,10 @@ modification_statement::process_where_clause(data_dictionary::database db, std::
|
||||
| boost::adaptors::transformed(std::mem_fn(&column_definition::name_as_text)));
|
||||
throw exceptions::invalid_request_exception(format("Invalid where clause contains non PRIMARY KEY columns: {}", column_names));
|
||||
}
|
||||
auto ck_restrictions = _restrictions->get_clustering_columns_restrictions();
|
||||
if (has_slice(ck_restrictions->expression) && !allow_clustering_key_slices()) {
|
||||
const expr::expression& ck_restrictions = _restrictions->get_clustering_columns_restrictions();
|
||||
if (has_slice(ck_restrictions) && !allow_clustering_key_slices()) {
|
||||
throw exceptions::invalid_request_exception(
|
||||
format("Invalid operator in where clause {}", to_string(ck_restrictions->expression)));
|
||||
format("Invalid operator in where clause {}", to_string(ck_restrictions)));
|
||||
}
|
||||
if (_restrictions->has_unrestricted_clustering_columns() && !applies_only_to_static_columns() && !s->is_dense()) {
|
||||
// Tomek: Origin had "&& s->comparator->is_composite()" in the condition below.
|
||||
@@ -415,13 +415,13 @@ modification_statement::process_where_clause(data_dictionary::database db, std::
|
||||
// Those tables don't have clustering columns so we wouldn't reach this code, thus
|
||||
// the check seems redundant.
|
||||
if (require_full_clustering_key()) {
|
||||
auto& col = s->column_at(column_kind::clustering_key, ck_restrictions->size());
|
||||
auto& col = s->column_at(column_kind::clustering_key, _restrictions->clustering_columns_restrictions_size());
|
||||
throw exceptions::invalid_request_exception(format("Missing mandatory PRIMARY KEY part {}", col.name_as_text()));
|
||||
}
|
||||
// In general, we can't modify specific columns if not all clustering columns have been specified.
|
||||
// However, if we modify only static columns, it's fine since we won't really use the prefix anyway.
|
||||
if (!has_slice(ck_restrictions->expression)) {
|
||||
auto& col = s->column_at(column_kind::clustering_key, ck_restrictions->size());
|
||||
if (!has_slice(ck_restrictions)) {
|
||||
auto& col = s->column_at(column_kind::clustering_key, _restrictions->clustering_columns_restrictions_size());
|
||||
for (auto&& op : _column_operations) {
|
||||
if (!op->column.is_static()) {
|
||||
throw exceptions::invalid_request_exception(format("Primary key column '{}' must be specified in order to modify column '{}'",
|
||||
|
||||
@@ -1944,12 +1944,12 @@ static bool needs_allow_filtering_anyway(
|
||||
if (strict_allow_filtering == flag_t::FALSE) {
|
||||
return false;
|
||||
}
|
||||
const auto& ck_restrictions = *restrictions.get_clustering_columns_restrictions();
|
||||
const auto& ck_restrictions = restrictions.get_clustering_columns_restrictions();
|
||||
const auto& pk_restrictions = restrictions.get_partition_key_restrictions();
|
||||
// Even if no filtering happens on the coordinator, we still warn about poor performance when partition
|
||||
// slice is defined but in potentially unlimited number of partitions (see #7608).
|
||||
if ((expr::is_empty_restriction(pk_restrictions) || has_token(pk_restrictions)) // Potentially unlimited partitions.
|
||||
&& !ck_restrictions.empty() // Slice defined.
|
||||
&& !expr::is_empty_restriction(ck_restrictions) // Slice defined.
|
||||
&& !restrictions.uses_secondary_indexing()) { // Base-table is used. (Index-table use always limits partitions.)
|
||||
if (strict_allow_filtering == flag_t::WARN) {
|
||||
warnings.emplace_back("This query should use ALLOW FILTERING and will be rejected in future versions.");
|
||||
|
||||
@@ -256,7 +256,7 @@ bool partition_key_matches(const schema& base, const view_info& view, const dht:
|
||||
}
|
||||
|
||||
bool clustering_prefix_matches(const schema& base, const view_info& view, const partition_key& key, const clustering_key_prefix& ck) {
|
||||
const auto r = view.select_statement().get_restrictions()->get_clustering_columns_restrictions();
|
||||
const cql3::expr::expression& r = view.select_statement().get_restrictions()->get_clustering_columns_restrictions();
|
||||
std::vector<bytes> exploded_pk = key.explode();
|
||||
std::vector<bytes> exploded_ck = ck.explode();
|
||||
std::vector<const column_definition*> ck_columns;
|
||||
@@ -269,7 +269,7 @@ bool clustering_prefix_matches(const schema& base, const view_info& view, const
|
||||
auto dummy_options = cql3::query_options({ });
|
||||
// FIXME: pass nullptrs for some of theses dummies
|
||||
return cql3::expr::is_satisfied_by(
|
||||
r->expression,
|
||||
r,
|
||||
cql3::expr::evaluation_inputs{
|
||||
.partition_key = &exploded_pk,
|
||||
.clustering_key = &exploded_ck,
|
||||
|
||||
Reference in New Issue
Block a user