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

Function scan

src/jrd/btr.cpp:6733–6960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6731
6732
6733static bool scan(thread_db* tdbb, UCHAR* pointer, RecordBitmap** bitmap, RecordBitmap* bitmap_and,
6734 index_desc* idx, const IndexRetrieval* retrieval, USHORT prefix,
6735 temporary_key* key,
6736 bool& skipLowerKey, const temporary_key& lowerKey, USHORT forceInclFlag)
6737{
6738/**************************************
6739 *
6740 * s c a n
6741 *
6742 **************************************
6743 *
6744 * Functional description
6745 * Do an index scan.
6746 * If we run over the bucket, return true.
6747 * If we're completely done (passed END_LEVEL),
6748 * return false.
6749 *
6750 **************************************/
6751 SET_TDBB(tdbb);
6752
6753 JRD_reschedule(tdbb);
6754
6755 // if the search key is flagged to indicate a multi-segment index
6756 // stuff the key to the stuff boundary
6757 ULONG count;
6758 USHORT flag = retrieval->irb_generic;
6759 flag &= ~forceInclFlag; // clear exclude bits if needed
6760
6761 if ((flag & irb_partial) && (flag & irb_equality) &&
6762 !(flag & irb_starting) && !(flag & irb_descending))
6763 {
6764 count = STUFF_COUNT - ((key->key_length + STUFF_COUNT) % (STUFF_COUNT + 1));
6765
6766 for (ULONG i = 0; i < count; i++)
6767 key->key_data[key->key_length + i] = 0;
6768
6769 count += key->key_length;
6770 }
6771 else
6772 count = key->key_length;
6773
6774 const USHORT to_segment = (idx->idx_count - retrieval->irb_upper_count);
6775 const UCHAR* const end_key = key->key_data + count;
6776 count -= key->key_length;
6777
6778 const bool descending = (flag & irb_descending);
6779 const bool equality = (flag & irb_equality);
6780 const bool ignoreNulls = (flag & irb_ignore_null_value_key) && (idx->idx_count == 1);
6781 bool done = false;
6782 bool ignore = false;
6783 const bool skipUpperKey = (flag & irb_exclude_upper);
6784 const bool partLower = (retrieval->irb_lower_count < idx->idx_count);
6785 const bool partUpper = (retrieval->irb_upper_count < idx->idx_count);
6786
6787 // Reset flags this routine does not check in the loop below
6788 flag &= ~(irb_equality | irb_unique | irb_ignore_null_value_key | irb_root_list_scan);
6789 flag &= ~(irb_exclude_lower | irb_exclude_upper);
6790

Callers 15

testMethod · 0.85
testMethod · 0.85
testMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
free_thread_dataMethod · 0.85

Calls 7

SET_TDBBFunction · 0.85
JRD_rescheduleFunction · 0.85
checkForLowerKeySkipFunction · 0.85
readNodeMethod · 0.80
testMethod · 0.45
getValueMethod · 0.45
getDefaultPoolMethod · 0.45

Tested by 11

testMethod · 0.68
testMethod · 0.68
testMethod · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68