MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / BTR_make_bounds

Function BTR_make_bounds

src/jrd/btr.cpp:1765–1851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1763
1764
1765bool BTR_make_bounds(thread_db* tdbb, const IndexRetrieval* retrieval,
1766 IndexScanListIterator* iterator,
1767 temporary_key* lower, temporary_key* upper,
1768 USHORT& forceInclFlag)
1769{
1770/**************************************
1771 *
1772 * B T R _ m a k e _ b o u n d s
1773 *
1774 **************************************
1775 *
1776 * Functional description
1777 * Construct search keys for lower/upper bounds for the given retrieval.
1778 *
1779 **************************************/
1780
1781 // If we already have a key, assume that we are looking for an equality
1782
1783 if (retrieval->irb_key)
1784 {
1785 copy_key(retrieval->irb_key, lower);
1786 copy_key(retrieval->irb_key, upper);
1787 }
1788 else
1789 {
1790 if (iterator && iterator->isEmpty())
1791 return false;
1792
1793 idx_e errorCode = idx_e_ok;
1794 const auto idx = &retrieval->irb_desc;
1795 forceInclFlag &= ~(irb_force_lower | irb_force_upper);
1796
1797 const USHORT keyType =
1798 (retrieval->irb_generic & irb_multi_starting) ? INTL_KEY_MULTI_STARTING :
1799 (retrieval->irb_generic & irb_starting) ? INTL_KEY_PARTIAL :
1800 (retrieval->irb_desc.idx_flags & idx_unique) ? INTL_KEY_UNIQUE :
1801 INTL_KEY_SORT;
1802
1803 bool forceIncludeUpper = false, forceIncludeLower = false;
1804
1805 if (const auto count = retrieval->irb_upper_count)
1806 {
1807 const auto values = iterator ? iterator->getUpperValues() :
1808 retrieval->irb_value + retrieval->irb_desc.idx_count;
1809
1810 errorCode = BTR_make_key(tdbb, count, values, retrieval->irb_scale,
1811 idx, upper, keyType, &forceIncludeUpper);
1812 }
1813
1814 if (errorCode == idx_e_ok)
1815 {
1816 if (const auto count = retrieval->irb_lower_count)
1817 {
1818 const auto values = iterator ? iterator->getLowerValues() :
1819 retrieval->irb_value;
1820
1821 errorCode = BTR_make_key(tdbb, count, values, retrieval->irb_scale,
1822 idx, lower, keyType, &forceIncludeLower);

Callers 2

BTR_evaluateFunction · 0.85
internalGetRecordMethod · 0.85

Calls 6

BTR_make_keyFunction · 0.85
getUpperValuesMethod · 0.80
getLowerValuesMethod · 0.80
copy_keyFunction · 0.70
isEmptyMethod · 0.45
raiseMethod · 0.45

Tested by

no test coverage detected