diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 7eadd3536b..8ed7d7efba 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -1186,7 +1186,6 @@ statement_restrictions::statement_restrictions(private_tag, if (idx_result.index) { _idx_opt = std::make_unique(std::move(*idx_result.index)); } - _idx_restrictions = std::move(idx_result.restrictions); _idx_column_predicates = std::move(idx_result.indexed_column_predicates); } @@ -1401,9 +1400,9 @@ static do_find_idx_result do_find_idx( return {chosen_index, chosen_index_restrictions, std::move(chosen_index_predicates)}; } -std::pair, expr::expression> +std::optional statement_restrictions::find_idx(const secondary_index::secondary_index_manager& sim) const { - return {_idx_opt ? std::optional(*_idx_opt) : std::nullopt, _idx_restrictions}; + return _idx_opt ? std::optional(*_idx_opt) : std::nullopt; } bool statement_restrictions::has_eq_restriction_on_column(const column_definition& column) const { diff --git a/cql3/restrictions/statement_restrictions.hh b/cql3/restrictions/statement_restrictions.hh index b14bbadc1d..5a6fff0167 100644 --- a/cql3/restrictions/statement_restrictions.hh +++ b/cql3/restrictions/statement_restrictions.hh @@ -227,7 +227,6 @@ private: std::vector _column_defs_for_filtering; schema_ptr _view_schema; std::unique_ptr _idx_opt; - expr::expression _idx_restrictions = expr::conjunction({}); std::vector _idx_column_predicates; ///< Predicates for the chosen index's target column. get_partition_key_ranges_fn_t _get_partition_key_ranges_fn; get_clustering_bounds_fn_t _get_clustering_bounds_fn; @@ -344,9 +343,8 @@ public: * Determines the index to be used with the restriction. * @param db - the data_dictionary::database context (for extracting index manager) * @return If an index can be used, an optional containing this index, otherwise an empty optional. - * In case the index is returned, second parameter returns the index restriction it uses. */ - std::pair, expr::expression> find_idx(const secondary_index::secondary_index_manager& sim) const; + std::optional find_idx(const secondary_index::secondary_index_manager& sim) const; /** * Checks if the partition key has some unrestricted components. diff --git a/cql3/statements/select_statement.cc b/cql3/statements/select_statement.cc index 2968ce191c..b94d82434c 100644 --- a/cql3/statements/select_statement.cc +++ b/cql3/statements/select_statement.cc @@ -1037,7 +1037,7 @@ view_indexed_table_select_statement::prepare(data_dictionary::database db, { auto cf = db.find_column_family(schema); auto& sim = cf.get_index_manager(); - auto [index_opt, used_index_restrictions] = restrictions->find_idx(sim); + auto index_opt = restrictions->find_idx(sim); if (!index_opt) { throw std::runtime_error("No index found."); @@ -1063,7 +1063,6 @@ view_indexed_table_select_statement::prepare(data_dictionary::database db, std::move(per_partition_limit), stats, *index_opt, - std::move(used_index_restrictions), view_schema, std::move(attrs)); @@ -1080,12 +1079,10 @@ view_indexed_table_select_statement::view_indexed_table_select_statement(schema_ std::optional per_partition_limit, cql_stats &stats, const secondary_index::index& index, - expr::expression used_index_restrictions, schema_ptr view_schema, std::unique_ptr attrs) : select_statement{schema, bound_terms, parameters, selection, restrictions, group_by_cell_indices, is_reversed, ordering_comparator, limit, per_partition_limit, stats, std::move(attrs)} , _index{index} - , _used_index_restrictions(std::move(used_index_restrictions)) , _view_schema(view_schema) { throwing_assert(_view_schema); diff --git a/cql3/statements/select_statement.hh b/cql3/statements/select_statement.hh index 2b61a9c154..e8b0a31ebe 100644 --- a/cql3/statements/select_statement.hh +++ b/cql3/statements/select_statement.hh @@ -186,7 +186,6 @@ public: class view_indexed_table_select_statement : public select_statement { secondary_index::index _index; - expr::expression _used_index_restrictions; schema_ptr _view_schema; noncopyable_function _get_partition_ranges_for_posting_list; noncopyable_function _get_partition_slice_for_posting_list; @@ -219,7 +218,6 @@ public: std::optional per_partition_limit, cql_stats &stats, const secondary_index::index& index, - expr::expression used_index_restrictions, schema_ptr view_schema, std::unique_ptr attrs); diff --git a/test/boost/statement_restrictions_test.cc b/test/boost/statement_restrictions_test.cc index 3d7efe5bf6..d1bd8bfded 100644 --- a/test/boost/statement_restrictions_test.cc +++ b/test/boost/statement_restrictions_test.cc @@ -414,7 +414,7 @@ SEASTAR_TEST_CASE(index_selection) { /*for_view=*/false, /*allow_filtering=*/true, restrictions::check_indexes::yes); - auto [idx, restrictions_expr] = sr->find_idx(sim); + auto idx = sr->find_idx(sim); return {where_clause, idx ? std::optional(idx->metadata().name()) : std::nullopt, sr->uses_secondary_indexing(), @@ -897,7 +897,7 @@ SEASTAR_TEST_CASE(combinatorial_restrictions) { ctx_msg("has_eq_restriction_on_column(fs)")); // --- Index selection --- - auto [idx_opt, idx_expr] = sr->find_idx(sim); + auto idx_opt = sr->find_idx(sim); // Determine expected index. The scoring algorithm: // - do_find_idx iterates _index_restrictions (PK group, then