diff --git a/compound.hh b/compound.hh index d3079af72c..9fa69ef06b 100644 --- a/compound.hh +++ b/compound.hh @@ -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()) { } diff --git a/schema.cc b/schema.cc index 2645f26797..291efe2e95 100644 --- a/schema.cc +++ b/schema.cc @@ -70,8 +70,7 @@ schema::make_column_specification(const column_definition& def) { void schema::rebuild() { _partition_key_type = make_lw_shared>(get_column_types(partition_key_columns())); - _clustering_key_type = make_lw_shared>(get_column_types(clustering_key_columns())); - _clustering_key_prefix_type = make_lw_shared(_clustering_key_type->as_prefix()); + _clustering_key_type = make_lw_shared(get_column_types(clustering_key_columns())); _columns_by_name.clear(); _regular_columns_by_name.clear(); diff --git a/schema.hh b/schema.hh index 0624c21d5e..8ea7fd7dcf 100644 --- a/schema.hh +++ b/schema.hh @@ -296,8 +296,7 @@ private: std::unordered_map _columns_by_name; std::map _regular_columns_by_name; lw_shared_ptr> _partition_key_type; - lw_shared_ptr> _clustering_key_type; - lw_shared_ptr> _clustering_key_prefix_type; + lw_shared_ptr> _clustering_key_type; friend class schema_builder; public: @@ -467,11 +466,11 @@ public: const lw_shared_ptr>& partition_key_type() const { return _partition_key_type; } - const lw_shared_ptr>& clustering_key_type() const { + const lw_shared_ptr>& clustering_key_type() const { return _clustering_key_type; } const lw_shared_ptr>& 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; diff --git a/tests/cql_query_test.cc b/tests/cql_query_test.cc index 2c7e033abe..0225f4c071 100644 --- a/tests/cql_query_test.cc +++ b/tests/cql_query_test.cc @@ -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) }, + }); + }); + }); +} + + diff --git a/thrift/handler.cc b/thrift/handler.cc index 2f107f2a82..15c587214c 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -606,7 +606,8 @@ private: } return sstring("org.apache.cassandra.db.marshal.") + it->second; } - static sstring class_from_compound_type(const compound_type& ct) { + template + static sstring class_from_compound_type(const compound_type& ct) { if (ct.is_singular()) { return class_from_data_type(ct.types().front()); }