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

Function find_page

src/jrd/btr.cpp:4936–5103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4934
4935
4936static ULONG find_page(btree_page* bucket, const temporary_key* key,
4937 const index_desc* idx, RecordNumber find_record_number,
4938 int retrieval)
4939{
4940/**************************************
4941 *
4942 * f i n d _ p a g e
4943 *
4944 **************************************
4945 *
4946 * Functional description
4947 * Find a page number in an index level. Return either the
4948 * node equal to the key or the last node less than the key.
4949 * Note that this routine can be called only for non-leaf
4950 * pages, because it assumes the first node on page is
4951 * a degenerate, zero-length node.
4952 *
4953 **************************************/
4954
4955 const bool leafPage = (bucket->btr_level == 0);
4956 bool firstPass = true;
4957 const bool descending = (idx->idx_flags & idx_descending);
4958 const bool primary = (idx->idx_flags & idx_primary);
4959 const bool unique = (idx->idx_flags & idx_unique);
4960 const bool key_all_nulls = (key->key_nulls == (1 << idx->idx_count) - 1);
4961 const bool validateDuplicates = (unique && !key_all_nulls) || primary;
4962
4963 if (validateDuplicates)
4964 find_record_number = NO_VALUE;
4965
4966 const UCHAR* const endPointer = (UCHAR*) bucket + bucket->btr_length;
4967
4968 USHORT prefix = 0; // last computed prefix against processed node
4969
4970 // pointer where to start reading next node
4971 UCHAR* pointer = find_area_start_point(bucket, key, 0, &prefix,
4972 descending, retrieval, find_record_number);
4973
4974 IndexNode node;
4975 pointer = node.readNode(pointer, leafPage);
4976 // Check if pointer is still valid
4977 if (pointer > endPointer)
4978 BUGCHECK(204); // msg 204 index inconsistent
4979
4980 if (node.isEndBucket || node.isEndLevel)
4981 {
4982 pointer = bucket->btr_nodes + bucket->btr_jump_size;
4983 pointer = node.readNode(pointer, leafPage);
4984
4985 // Check if pointer is still valid
4986 if (pointer > endPointer)
4987 BUGCHECK(204); // msg 204 index inconsistent
4988 }
4989
4990 if (node.isEndLevel)
4991 BUGCHECK(206); // msg 206 exceeded index level
4992
4993 ULONG previousNumber = node.pageNumber;

Callers 3

BTR_find_pageFunction · 0.85
add_nodeFunction · 0.85
remove_nodeFunction · 0.85

Calls 2

find_area_start_pointFunction · 0.85
readNodeMethod · 0.80

Tested by

no test coverage detected