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

Function checkForLowerKeySkip

src/jrd/btr.cpp:1057–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1055
1056
1057static void checkForLowerKeySkip(bool& skipLowerKey,
1058 const bool partLower,
1059 const IndexNode& node,
1060 const temporary_key& lower,
1061 const index_desc& idx,
1062 const IndexRetrieval* retrieval)
1063{
1064 if (node.prefix == 0)
1065 {
1066 // If the prefix is 0 we have a full key.
1067 // (first node on every new page for example has prefix zero)
1068 if (partLower)
1069 {
1070 // With multi-segment compare first part of data with lowerKey
1071 skipLowerKey = ((lower.key_length <= node.length) &&
1072 (memcmp(node.data, lower.key_data, lower.key_length) == 0));
1073
1074 if (skipLowerKey && (node.length > lower.key_length))
1075 {
1076 // We've bigger data in the node than in the lowerKey,
1077 // now check the segment-number
1078 const UCHAR* segp = node.data + lower.key_length;
1079
1080 const USHORT segnum =
1081 idx.idx_count - (UCHAR)((idx.idx_flags & idx_descending) ? ((*segp) ^ -1) : *segp);
1082
1083 if (segnum < retrieval->irb_lower_count)
1084 skipLowerKey = false;
1085 }
1086 }
1087 else
1088 {
1089 // Compare full data with lowerKey
1090 skipLowerKey = ((lower.key_length == node.length) &&
1091 (memcmp(node.data, lower.key_data, lower.key_length) == 0));
1092 }
1093 }
1094 else
1095 {
1096 if ((lower.key_length == node.prefix + node.length) ||
1097 ((lower.key_length <= node.prefix + node.length) && partLower))
1098 {
1099 const UCHAR* p = node.data, *q = lower.key_data + node.prefix;
1100 const UCHAR* const end = lower.key_data + lower.key_length;
1101 while (q < end)
1102 {
1103 if (*p++ != *q++)
1104 {
1105 skipLowerKey = false;
1106 break;
1107 }
1108 }
1109
1110 if ((q >= end) && (p < node.data + node.length) && skipLowerKey && partLower)
1111 {
1112 const bool descending = idx.idx_flags & idx_descending;
1113
1114 // since key length always is multiplier of (STUFF_COUNT + 1) (for partial

Callers 2

BTR_evaluateFunction · 0.85
scanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected