db: Fix trim_clustering_row_ranges_to() for non-full keys and reverse order
trim_clustering_row_ranges_to() is broken for non-full keys in reverse mode. It will trim the range to position_in_partition_view::after_key(full_key) instead of position_in_partition_view::before_key(key), hence it will include the key in the resulting range rather than exclude it. Fixes #12180 Refs #1446
This commit is contained in:
5
query.cc
5
query.cc
@@ -135,14 +135,13 @@ void trim_clustering_row_ranges_to(const schema& s, clustering_row_ranges& range
|
||||
}
|
||||
|
||||
void trim_clustering_row_ranges_to(const schema& s, clustering_row_ranges& ranges, const clustering_key& key, bool reversed) {
|
||||
if (key.is_full(s)) {
|
||||
if (key.is_full(s) || reversed) {
|
||||
return trim_clustering_row_ranges_to(s, ranges,
|
||||
reversed ? position_in_partition_view::before_key(key) : position_in_partition_view::after_key(key), reversed);
|
||||
}
|
||||
auto full_key = key;
|
||||
clustering_key::make_full(s, full_key);
|
||||
return trim_clustering_row_ranges_to(s, ranges,
|
||||
reversed ? position_in_partition_view::after_key(full_key) : position_in_partition_view::before_key(full_key), reversed);
|
||||
return trim_clustering_row_ranges_to(s, ranges, position_in_partition_view::before_key(full_key), reversed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1595,13 +1595,13 @@ SEASTAR_TEST_CASE(test_trim_clustering_row_ranges_to) {
|
||||
check_reversed(
|
||||
{ {excl{9, 39}, incl{10}} },
|
||||
{10},
|
||||
{ {excl{9, 39}, incl{10, null{}}} });
|
||||
{ {excl{9, 39}, excl{10}} });
|
||||
|
||||
// (13)
|
||||
check_reversed(
|
||||
{ {incl{9, 10}, incl{10, 30}} },
|
||||
{10},
|
||||
{ {incl{9, 10}, incl{10, null{}}} });
|
||||
{ {incl{9, 10}, excl{10}} });
|
||||
|
||||
// (14)
|
||||
check_reversed(
|
||||
|
||||
Reference in New Issue
Block a user