From a1167b443139d11172c717e08403c0eae22009e8 Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Thu, 24 Oct 2024 12:43:01 +0300 Subject: [PATCH] Fix #8290: 'Unique scan' is incorrectly reported in the explained plan for unique index and IS NULL predicate --- src/jrd/recsrc/RecordSource.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jrd/recsrc/RecordSource.cpp b/src/jrd/recsrc/RecordSource.cpp index 097159af1f..cb65597aa0 100644 --- a/src/jrd/recsrc/RecordSource.cpp +++ b/src/jrd/recsrc/RecordSource.cpp @@ -203,6 +203,7 @@ void RecordSource::printInversion(thread_db* tdbb, const InversionNode* inversio } const index_desc& idx = retrieval->irb_desc; + const bool primaryIdx = (idx.idx_flags & idx_primary); const bool uniqueIdx = (idx.idx_flags & idx_unique); const USHORT segCount = idx.idx_count; @@ -214,7 +215,13 @@ void RecordSource::printInversion(thread_db* tdbb, const InversionNode* inversio const bool fullscan = (maxSegs == 0); const bool list = (retrieval->irb_list != nullptr); - const bool unique = !list && uniqueIdx && equality && (minSegs == segCount); + + bool unique = false; + if (!list && equality && minSegs == segCount) + { + unique = (retrieval->irb_generic & irb_ignore_null_value_key) ? + uniqueIdx : primaryIdx; + } string bounds; if (!unique && !fullscan)