schema: Dense schemas are correctly upgrades
When upgrading a dense schema, we would drop the cells of the regular (compact) column. This patch fixes this by making the regular and compact column kinds compatible. Fixes #1536 Signed-off-by: Duarte Nunes <duarte@scylladb.com> Message-Id: <1470172097-7719-1-git-send-email-duarte@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
99dfbedf36
commit
89b40f54db
@@ -35,7 +35,7 @@ class converting_mutation_partition_applier : public mutation_partition_visitor
|
||||
deletable_row* _current_row;
|
||||
private:
|
||||
static bool is_compatible(const column_definition& new_def, const data_type& old_type, column_kind kind) {
|
||||
return new_def.kind == kind && new_def.type->is_value_compatible_with(*old_type);
|
||||
return ::is_compatible(new_def.kind, kind) && new_def.type->is_value_compatible_with(*old_type);
|
||||
}
|
||||
void accept_cell(row& dst, column_kind kind, const column_definition& new_def, const data_type& old_type, atomic_cell_view cell) {
|
||||
if (is_compatible(new_def, old_type, kind) && cell.timestamp() > new_def.dropped_at()) {
|
||||
|
||||
@@ -56,6 +56,14 @@ sstring to_sstring(index_type t) {
|
||||
throw std::invalid_argument("unknown index type");
|
||||
}
|
||||
|
||||
bool is_regular(column_kind k) {
|
||||
return k == column_kind::regular_column || k == column_kind::compact_column;
|
||||
}
|
||||
|
||||
bool is_compatible(column_kind k1, column_kind k2) {
|
||||
return k1 == k2 || (is_regular(k1) && is_regular(k2));
|
||||
}
|
||||
|
||||
column_mapping_entry::column_mapping_entry(bytes name, sstring type_name)
|
||||
: _name(std::move(name))
|
||||
, _type(db::marshal::type_parser::parse(type_name))
|
||||
|
||||
@@ -72,6 +72,8 @@ void read_collections(schema_builder& builder, sstring comparator);
|
||||
enum class column_kind { partition_key, clustering_key, static_column, regular_column, compact_column };
|
||||
|
||||
sstring to_sstring(column_kind k);
|
||||
bool is_regular(column_kind k);
|
||||
bool is_compatible(column_kind k1, column_kind k2);
|
||||
|
||||
// CMH this is also manually defined in thrift gen file.
|
||||
enum class index_type {
|
||||
@@ -225,7 +227,7 @@ public:
|
||||
index_info idx_info;
|
||||
|
||||
bool is_static() const { return kind == column_kind::static_column; }
|
||||
bool is_regular() const { return kind == column_kind::regular_column || kind == column_kind::compact_column; }
|
||||
bool is_regular() const { return ::is_regular(kind); }
|
||||
bool is_partition_key() const { return kind == column_kind::partition_key; }
|
||||
bool is_clustering_key() const { return kind == column_kind::clustering_key; }
|
||||
bool is_primary_key() const { return kind == column_kind::partition_key || kind == column_kind::clustering_key; }
|
||||
|
||||
Reference in New Issue
Block a user