From 3e4fb7cad649cedc24d13278e8c592a7f2c4359b Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 20 Apr 2023 09:32:49 +0300 Subject: [PATCH] view_info: Add data_dictionary argument to select_statement() This method needs data_dictionary to work. Fortunately, all callers of it already have the dictionary at hand and can just pass it as argument. Signed-off-by: Pavel Emelyanov --- db/view/view.cc | 12 ++++++------ view_info.hh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/view/view.cc b/db/view/view.cc index bb45187cd7..228b5994e6 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -79,7 +79,7 @@ view_info::view_info(const schema& schema, const raw_view_info& raw_view_info) , _has_computed_column_depending_on_base_non_primary_key(false) { } -cql3::statements::select_statement& view_info::select_statement() const { +cql3::statements::select_statement& view_info::select_statement(data_dictionary::database db) const { if (!_select_statement) { std::unique_ptr raw; // FIXME(sarna): legacy code, should be removed after "computed_columns" feature is guaranteed @@ -111,7 +111,7 @@ cql3::statements::select_statement& view_info::select_statement() const { const query::partition_slice& view_info::partition_slice(data_dictionary::database db) const { if (!_partition_slice) { - _partition_slice = select_statement().make_partition_slice(cql3::query_options({ })); + _partition_slice = select_statement(db).make_partition_slice(cql3::query_options({ })); } return *_partition_slice; } @@ -274,7 +274,7 @@ void stats::register_stats() { } bool partition_key_matches(data_dictionary::database db, const schema& base, const view_info& view, const dht::decorated_key& key) { - const cql3::expr::expression& pk_restrictions = view.select_statement().get_restrictions()->get_partition_key_restrictions(); + const cql3::expr::expression& pk_restrictions = view.select_statement(db).get_restrictions()->get_partition_key_restrictions(); std::vector exploded_pk = key.key().explode(); std::vector exploded_ck; std::vector pk_columns; @@ -299,7 +299,7 @@ bool partition_key_matches(data_dictionary::database db, const schema& base, con } bool clustering_prefix_matches(data_dictionary::database db, const schema& base, const view_info& view, const partition_key& key, const clustering_key_prefix& ck) { - const cql3::expr::expression& r = view.select_statement().get_restrictions()->get_clustering_columns_restrictions(); + const cql3::expr::expression& r = view.select_statement(db).get_restrictions()->get_clustering_columns_restrictions(); std::vector exploded_pk = key.explode(); std::vector exploded_ck = ck.explode(); std::vector ck_columns; @@ -384,7 +384,7 @@ public: bool check_if_matches(const clustering_key& key, const query::result_row_view& static_row, const query::result_row_view& row) const { std::vector ck = key.explode(); return boost::algorithm::all_of( - _view.select_statement().get_restrictions()->get_non_pk_restriction() | boost::adaptors::map_values, + _view.select_statement(_db).get_restrictions()->get_non_pk_restriction() | boost::adaptors::map_values, [&] (auto&& r) { // FIXME: move outside all_of(). However, crashes. auto static_and_regular_columns = cql3::expr::get_non_pk_values(*_selection, static_row, &row); @@ -1472,7 +1472,7 @@ future calculate_affected_clustering_ranges(data_d if (mp.partition_tombstone() || !mp.row_tombstones().empty()) { for (auto&& v : views) { // FIXME: #2371 - if (v.view->view_info()->select_statement().get_restrictions()->has_unrestricted_clustering_columns()) { + if (v.view->view_info()->select_statement(db).get_restrictions()->has_unrestricted_clustering_columns()) { view_row_ranges.push_back(nonwrapping_range::make_open_ended_both_sides()); break; } diff --git a/view_info.hh b/view_info.hh index dfccf3458c..2c24add3f0 100644 --- a/view_info.hh +++ b/view_info.hh @@ -48,7 +48,7 @@ public: return _raw.where_clause(); } - cql3::statements::select_statement& select_statement() const; + cql3::statements::select_statement& select_statement(data_dictionary::database) const; const query::partition_slice& partition_slice(data_dictionary::database) const; const column_definition* view_column(const schema& base, column_kind kind, column_id base_id) const; const column_definition* view_column(const column_definition& base_def) const;