mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 14:33:08 +00:00
Merge branch 'pdziepak/fix-clustering-key-comparison/v2' fom seastar-dev.git
From Paweł: This series fixes comparison of byte order comparable clustering keys. Fixes #645.
This commit is contained in:
@@ -68,7 +68,7 @@ public:
|
||||
, _byte_order_equal(std::all_of(_types.begin(), _types.end(), [] (auto t) {
|
||||
return t->is_byte_order_equal();
|
||||
}))
|
||||
, _byte_order_comparable(_types.size() == 1 && _types[0]->is_byte_order_comparable())
|
||||
, _byte_order_comparable(!is_prefixable && _types.size() == 1 && _types[0]->is_byte_order_comparable())
|
||||
, _is_reversed(_types.size() == 1 && _types[0]->is_reversed())
|
||||
{ }
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ schema::make_column_specification(const column_definition& def) {
|
||||
|
||||
void schema::rebuild() {
|
||||
_partition_key_type = make_lw_shared<compound_type<>>(get_column_types(partition_key_columns()));
|
||||
_clustering_key_type = make_lw_shared<compound_type<>>(get_column_types(clustering_key_columns()));
|
||||
_clustering_key_prefix_type = make_lw_shared(_clustering_key_type->as_prefix());
|
||||
_clustering_key_type = make_lw_shared<compound_prefix>(get_column_types(clustering_key_columns()));
|
||||
|
||||
_columns_by_name.clear();
|
||||
_regular_columns_by_name.clear();
|
||||
|
||||
@@ -296,8 +296,7 @@ private:
|
||||
std::unordered_map<bytes, const column_definition*> _columns_by_name;
|
||||
std::map<bytes, const column_definition*, serialized_compare> _regular_columns_by_name;
|
||||
lw_shared_ptr<compound_type<allow_prefixes::no>> _partition_key_type;
|
||||
lw_shared_ptr<compound_type<allow_prefixes::no>> _clustering_key_type;
|
||||
lw_shared_ptr<compound_type<allow_prefixes::yes>> _clustering_key_prefix_type;
|
||||
lw_shared_ptr<compound_type<allow_prefixes::yes>> _clustering_key_type;
|
||||
|
||||
friend class schema_builder;
|
||||
public:
|
||||
@@ -467,11 +466,11 @@ public:
|
||||
const lw_shared_ptr<compound_type<allow_prefixes::no>>& partition_key_type() const {
|
||||
return _partition_key_type;
|
||||
}
|
||||
const lw_shared_ptr<compound_type<allow_prefixes::no>>& clustering_key_type() const {
|
||||
const lw_shared_ptr<compound_type<allow_prefixes::yes>>& clustering_key_type() const {
|
||||
return _clustering_key_type;
|
||||
}
|
||||
const lw_shared_ptr<compound_type<allow_prefixes::yes>>& clustering_key_prefix_type() const {
|
||||
return _clustering_key_prefix_type;
|
||||
return _clustering_key_type;
|
||||
}
|
||||
const data_type& regular_column_name_type() const {
|
||||
return _raw._regular_column_name_type;
|
||||
|
||||
@@ -1967,3 +1967,34 @@ SEASTAR_TEST_CASE(test_collections_of_collections) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
SEASTAR_TEST_CASE(test_result_order) {
|
||||
return do_with_cql_env([] (auto& e) {
|
||||
return e.execute_cql("create table tro (p1 int, c1 text, r1 int, PRIMARY KEY (p1, c1)) with compact storage;").discard_result().then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'z', 1);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'bbbb', 2);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'a', 3);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'aaa', 4);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'bb', 5);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("insert into tro (p1, c1, r1) values (1, 'cccc', 6);").discard_result();
|
||||
}).then([&e] {
|
||||
return e.execute_cql("select * from tro where p1 = 1;");
|
||||
}).then([&e] (auto msg) {
|
||||
assert_that(msg).is_rows().with_rows({
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("a")), int32_type->decompose(3) },
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("aaa")), int32_type->decompose(4) },
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("bb")), int32_type->decompose(5) },
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("bbbb")), int32_type->decompose(2) },
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("cccc")), int32_type->decompose(6) },
|
||||
{ int32_type->decompose(1), utf8_type->decompose(sstring("z")), int32_type->decompose(1) },
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -606,7 +606,8 @@ private:
|
||||
}
|
||||
return sstring("org.apache.cassandra.db.marshal.") + it->second;
|
||||
}
|
||||
static sstring class_from_compound_type(const compound_type<allow_prefixes::no>& ct) {
|
||||
template<allow_prefixes IsPrefixable>
|
||||
static sstring class_from_compound_type(const compound_type<IsPrefixable>& ct) {
|
||||
if (ct.is_singular()) {
|
||||
return class_from_data_type(ct.types().front());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user