From 3210dee4a6bf885058d7bbde4e62a2b2e1e99d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Thu, 18 Nov 2021 08:48:21 +0200 Subject: [PATCH] multishard_mutation_query: fix reverse scans The read itself has to be done with the reversed schema (query schema) but the result building has to be done with the table schema. For data queries this doesn't matter, but replicate the distinction for consistency (and because this might change). --- multishard_mutation_query.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/multishard_mutation_query.cc b/multishard_mutation_query.cc index f59faed76e..6272bafdd7 100644 --- a/multishard_mutation_query.cc +++ b/multishard_mutation_query.cc @@ -805,30 +805,31 @@ public: future>, cache_temperature>> query_mutations_on_all_shards( distributed& db, - schema_ptr s, + schema_ptr table_schema, const query::read_command& cmd, const dht::partition_range_vector& ranges, tracing::trace_state_ptr trace_state, db::timeout_clock::time_point timeout) { - return do_query_on_all_shards(db, s, cmd, ranges, std::move(trace_state), timeout, - [s, &cmd] (query::result_memory_accounter&& accounter) { - return mutation_query_result_builder(*s, cmd.slice, std::move(accounter)); + schema_ptr query_schema = cmd.slice.is_reversed() ? table_schema->make_reversed() : table_schema; + + return do_query_on_all_shards(db, query_schema, cmd, ranges, std::move(trace_state), timeout, + [table_schema, &cmd] (query::result_memory_accounter&& accounter) { + return mutation_query_result_builder(*table_schema, cmd.slice, std::move(accounter)); }); } future>, cache_temperature>> query_data_on_all_shards( distributed& db, - schema_ptr s, + schema_ptr table_schema, const query::read_command& cmd, const dht::partition_range_vector& ranges, query::result_options opts, tracing::trace_state_ptr trace_state, db::timeout_clock::time_point timeout) { - if (cmd.slice.is_reversed()) { - s = s->make_reversed(); - } - return do_query_on_all_shards(db, s, cmd, ranges, std::move(trace_state), timeout, - [s, &cmd, opts] (query::result_memory_accounter&& accounter) { - return data_query_result_builder(*s, cmd.slice, opts, std::move(accounter)); + schema_ptr query_schema = cmd.slice.is_reversed() ? table_schema->make_reversed() : table_schema; + + return do_query_on_all_shards(db, query_schema, cmd, ranges, std::move(trace_state), timeout, + [table_schema, &cmd, opts] (query::result_memory_accounter&& accounter) { + return data_query_result_builder(*table_schema, cmd.slice, opts, std::move(accounter)); }); }