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

Function find_node_start_point

src/jrd/btr.cpp:4562–4709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4560
4561
4562static UCHAR* find_node_start_point(btree_page* bucket, temporary_key* key,
4563 UCHAR* value,
4564 USHORT* return_value, bool descending,
4565 int retrieval, bool pointer_by_marker,
4566 RecordNumber find_record_number)
4567{
4568/**************************************
4569 *
4570 * f i n d _ n o d e _ s t a r t _ p o i n t
4571 *
4572 **************************************
4573 *
4574 * Functional description
4575 * Locate and return a pointer to the insertion point.
4576 * If the key doesn't belong in this bucket, return NULL.
4577 * A flag indicates the index is descending.
4578 *
4579 **************************************/
4580
4581 USHORT prefix = 0;
4582 const UCHAR* const key_end = key->key_data + key->key_length;
4583 bool firstPass = true;
4584 const bool leafPage = (bucket->btr_level == 0);
4585 const UCHAR* const endPointer = (UCHAR*) bucket + bucket->btr_length;
4586
4587 // Find point where we can start search.
4588 UCHAR* pointer = find_area_start_point(bucket, key, value, &prefix, descending, retrieval,
4589 find_record_number);
4590 const UCHAR* p = key->key_data + prefix;
4591
4592 IndexNode node;
4593 pointer = node.readNode(pointer, leafPage);
4594
4595 // Check if pointer is still valid
4596 if (pointer > endPointer)
4597 BUGCHECK(204); // msg 204 index inconsistent
4598
4599 // If this is an non-leaf bucket of a descending index, the dummy node on the
4600 // front will trip us up. NOTE: This code may be apocryphal. I don't see
4601 // anywhere that a dummy node is stored for a descending index. - deej
4602 //
4603 // AB: This node ("dummy" node) is inserted on every first page in a level.
4604 // Because it's length and prefix is 0 a descending index would see it
4605 // always as the first matching node.
4606 if (!leafPage && descending &&
4607 (node.nodePointer == bucket->btr_nodes + bucket->btr_jump_size) && (node.length == 0))
4608 {
4609 pointer = node.readNode(pointer, leafPage);
4610
4611 // Check if pointer is still valid
4612 if (pointer > endPointer)
4613 BUGCHECK(204); // msg 204 index inconsistent
4614 }
4615
4616 while (true)
4617 {
4618 // Pick up data from node
4619 if (value && node.length)

Callers 4

BTR_evaluateFunction · 0.85
BTR_find_leafFunction · 0.85
insert_nodeFunction · 0.85
remove_leaf_nodeFunction · 0.85

Calls 2

find_area_start_pointFunction · 0.85
readNodeMethod · 0.80

Tested by

no test coverage detected