diff --git a/src/Interpreters/Set.cpp b/src/Interpreters/Set.cpp index b1e79602de92..2694ce8d893a 100644 --- a/src/Interpreters/Set.cpp +++ b/src/Interpreters/Set.cpp @@ -761,7 +761,17 @@ BoolMask MergeTreeSetIndex::checkInRange(const std::vector & key_ranges, }) - indices.begin(); if (begin > end) + { + /// TODO: Remove the #ifndef and always throw after + /// https://github.com/ClickHouse/ClickHouse/issues/90461 is fixed. + /// (What happens here is: the applyMonotonicFunctionsChainToRange call above applies + /// nonmonotonic functions, and we end up with left > right.) +#ifndef NDEBUG throw Exception(ErrorCodes::LOGICAL_ERROR, "Invalid binary search result in MergeTreeSetIndex"); +#else + return {true, true}; +#endif + } bool can_be_true = begin < end; diff --git a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 129af1d9697e..0f38c74d7cce 100644 --- a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -1715,11 +1715,17 @@ MarkRanges MergeTreeDataSelectExecutor::markRangesFromPKRange( if (check_in_range(result_exact_range, BoolMask::consider_only_can_be_false).can_be_false) { /// key_condition.matchesExactContinuousRange returned true, but the - /// range doesn't seem to be continuous. + /// range doesn't seem to be continuous. Something's broken. + /// TODO: Remove the #ifndef and always throw after + /// https://github.com/ClickHouse/ClickHouse/issues/90461 is fixed. +#ifndef NDEBUG throw Exception(ErrorCodes::LOGICAL_ERROR, "Inconsistent KeyCondition behavior"); +#endif + } + else + { + exact_ranges->emplace_back(std::move(result_exact_range)); } - - exact_ranges->emplace_back(std::move(result_exact_range)); } } }