@@ -1797,16 +1797,15 @@ bool BTR_make_bounds(thread_db* tdbb, const IndexRetrieval* retrieval,
1797
1797
(retrieval->irb_desc .idx_flags & idx_unique) ? INTL_KEY_UNIQUE :
1798
1798
INTL_KEY_SORT;
1799
1799
1800
+ bool forceIncludeUpper = false , forceIncludeLower = false ;
1801
+
1800
1802
if (const auto count = retrieval->irb_upper_count )
1801
1803
{
1802
1804
const auto values = iterator ? iterator->getUpperValues () :
1803
1805
retrieval->irb_value + retrieval->irb_desc .idx_count ;
1804
1806
1805
- bool forceInclude = false ;
1806
1807
errorCode = BTR_make_key (tdbb, count, values, retrieval->irb_scale ,
1807
- idx, upper, keyType, &forceInclude);
1808
- if (forceInclude)
1809
- forceInclFlag |= irb_force_upper;
1808
+ idx, upper, keyType, &forceIncludeUpper);
1810
1809
}
1811
1810
1812
1811
if (errorCode == idx_e_ok)
@@ -1816,11 +1815,8 @@ bool BTR_make_bounds(thread_db* tdbb, const IndexRetrieval* retrieval,
1816
1815
const auto values = iterator ? iterator->getLowerValues () :
1817
1816
retrieval->irb_value ;
1818
1817
1819
- bool forceInclude = false ;
1820
1818
errorCode = BTR_make_key (tdbb, count, values, retrieval->irb_scale ,
1821
- idx, lower, keyType, &forceInclude);
1822
- if (forceInclude)
1823
- forceInclFlag |= irb_force_lower;
1819
+ idx, lower, keyType, &forceIncludeLower);
1824
1820
}
1825
1821
}
1826
1822
@@ -1830,6 +1826,22 @@ bool BTR_make_bounds(thread_db* tdbb, const IndexRetrieval* retrieval,
1830
1826
IndexErrorContext context (retrieval->irb_relation , &temp_idx);
1831
1827
context.raise (tdbb, errorCode);
1832
1828
}
1829
+
1830
+ // If retrieval is flagged to ignore NULLs and any segment of the key
1831
+ // to be matched contains NULL, don't bother with a scan
1832
+
1833
+ if ((retrieval->irb_generic & irb_ignore_null_value_key) &&
1834
+ ((retrieval->irb_upper_count && upper->key_nulls ) ||
1835
+ (retrieval->irb_lower_count && lower->key_nulls )))
1836
+ {
1837
+ return false ;
1838
+ }
1839
+
1840
+ if (forceIncludeUpper)
1841
+ forceInclFlag |= irb_force_upper;
1842
+
1843
+ if (forceIncludeLower)
1844
+ forceInclFlag |= irb_force_lower;
1833
1845
}
1834
1846
1835
1847
return true ;
0 commit comments