From 7886c9cd935ce1bf36818aac58bca33395fbbadb Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Thu, 24 Oct 2024 12:41:16 +0300 Subject: [PATCH] Fix #8291: NULLs should be skipped during index navigation when there's no lower bound and matched conditions are known to ignore NULLs --- src/jrd/optimizer/Retrieval.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jrd/optimizer/Retrieval.cpp b/src/jrd/optimizer/Retrieval.cpp index c71a452b84..668859e283 100644 --- a/src/jrd/optimizer/Retrieval.cpp +++ b/src/jrd/optimizer/Retrieval.cpp @@ -1211,9 +1211,15 @@ InversionNode* Retrieval::makeIndexScanNode(IndexScratch* indexScratch) const // This index is never used for IS NULL, thus we can ignore NULLs // already at index scan. But this rule doesn't apply to nod_equiv // which requires NULLs to be found in the index. - // A second exception is when this index is used for navigation. - if (ignoreNullsOnScan && !(idx->idx_runtime_flags & idx_navigate)) + // + // dimitr: make sure the check below is never moved outside the IF scope, + // as this flag must not be set for a full index scan, + // see also the assertion below + if (ignoreNullsOnScan) + { + fb_assert(indexScratch->lowerCount || indexScratch->upperCount); retrieval->irb_generic |= irb_ignore_null_value_key; + } const auto& lastSegment = segments[count - 1];