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

Method lookupRecord

src/jrd/replication/Applier.cpp:1096–1198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094}
1095
1096bool Applier::lookupRecord(thread_db* tdbb,
1097 jrd_rel* relation, Record* record,
1098 index_desc& idx, const MetaName* idxName)
1099{
1100 RecordBitmap::reset(m_bitmap);
1101
1102 // Special case: RDB$DATABASE has no keys but it's guaranteed to have only one record
1103 if (relation->rel_id == rel_database)
1104 {
1105 RBM_SET(tdbb->getDefaultPool(), &m_bitmap, 0);
1106 return false;
1107 }
1108
1109 bool haveIdx = false;
1110 if (idxName && idxName->hasData())
1111 {
1112 SLONG foundRelId;
1113 IndexStatus idxStatus;
1114 SLONG idx_id = MET_lookup_index_name(tdbb, *idxName, &foundRelId, &idxStatus);
1115
1116 fb_assert(idxStatus == MET_object_active);
1117 fb_assert(foundRelId == relation->rel_id);
1118
1119 haveIdx = (idx_id >= 0) && (idxStatus == MET_object_active) && (foundRelId == relation->rel_id) &&
1120 BTR_lookup(tdbb, relation, idx_id, &idx, relation->getPages(tdbb));
1121 }
1122
1123 if (!haveIdx)
1124 haveIdx = lookupKey(tdbb, relation, idx);
1125
1126 if (haveIdx)
1127 {
1128 IndexKey key(tdbb, relation, &idx);
1129 if (const auto result = key.compose(record))
1130 {
1131 IndexErrorContext context(relation, &idx);
1132 context.raise(tdbb, result, record);
1133 }
1134
1135 IndexRetrieval retrieval(relation, &idx, idx.idx_count, key);
1136 retrieval.irb_generic = irb_equality | (idx.idx_flags & idx_descending ? irb_descending : 0);
1137
1138 BTR_evaluate(tdbb, &retrieval, &m_bitmap, NULL);
1139 return true;
1140 }
1141
1142 NoKeyTable* table = NULL;
1143
1144 for (size_t i = 0; i < FB_NELEM(NO_KEY_TABLES); i++)
1145 {
1146 const auto tab = &NO_KEY_TABLES[i];
1147
1148 if (tab->rel_id == relation->rel_id)
1149 {
1150 table = tab;
1151 break;
1152 }
1153 }

Callers

nothing calls this directly

Calls 15

BTR_lookupFunction · 0.85
BTR_evaluateFunction · 0.85
RLCK_reserve_relationFunction · 0.85
VIO_next_recordFunction · 0.85
EVL_fieldFunction · 0.85
MOV_compareFunction · 0.85
raiseErrorFunction · 0.70
resetFunction · 0.50
getDefaultPoolMethod · 0.45
hasDataMethod · 0.45
getPagesMethod · 0.45
composeMethod · 0.45

Tested by

no test coverage detected