view info: has_computed_column_depending_on_base_non_primary_key

In case of secondary indexes, if an index does not contain any column from
the base which makes up for the primary key, then it is assumed that
during update, a change to some cells from the base table cannot cause
that we're dealing with a different row in the view. This however
doesn't take into account the possibility of computed columns which in
fact do depend on some non-primary-key columns. Introduce additional
property of an index,
has_computed_column_depending_on_base_non_primary_key.
This commit is contained in:
Michał Radwański
2022-05-18 17:37:41 +02:00
committed by Nadav Har'El
parent 4cfd264e5d
commit 112086767c
2 changed files with 8 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ static inline void inject_failure(std::string_view operation) {
view_info::view_info(const schema& schema, const raw_view_info& raw_view_info)
: _schema(schema)
, _raw(raw_view_info)
, _has_computed_column_depending_on_base_non_primary_key(false)
{ }
cql3::statements::select_statement& view_info::select_statement() const {
@@ -167,6 +168,9 @@ db::view::base_info_ptr view_info::make_base_dependent_view_info(const schema& b
for (auto&& view_col : boost::range::join(_schema.partition_key_columns(), _schema.clustering_key_columns())) {
if (view_col.is_computed()) {
// we are not going to find it in the base table...
if (view_col.get_computation().depends_on_non_primary_key_column()) {
_has_computed_column_depending_on_base_non_primary_key = true;
}
continue;
}
const bytes& view_col_name = view_col.name();

View File

@@ -24,6 +24,7 @@ class view_info final {
mutable shared_ptr<cql3::statements::select_statement> _select_statement;
mutable std::optional<query::partition_slice> _partition_slice;
db::view::base_info_ptr _base_info;
mutable bool _has_computed_column_depending_on_base_non_primary_key;
public:
view_info(const schema& schema, const raw_view_info& raw_view_info);
@@ -52,6 +53,9 @@ public:
const column_definition* view_column(const schema& base, column_id base_id) const;
const column_definition* view_column(const column_definition& base_def) const;
bool has_base_non_pk_columns_in_view_pk() const;
bool has_computed_column_depending_on_base_non_primary_key() const {
return _has_computed_column_depending_on_base_non_primary_key;
}
/// Returns a pointer to the base_dependent_view_info which matches the current
/// schema of the base table.