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

Method compareKeys

src/jrd/recsrc/SortedStream.cpp:286–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286bool SortedStream::compareKeys(const UCHAR* p, const UCHAR* q) const
287{
288 if (!memcmp(p, q, m_map->keyLength))
289 return true;
290
291 if (!(m_map->flags & FLAG_KEY_VARY))
292 return false;
293
294 // Binary-distinct varying length string keys may in fact be equal.
295 // Re-check the keys at the higher level. See CORE-4909.
296
297 fb_assert(m_map->keyItems.getCount() % 2 == 0);
298 const USHORT count = m_map->keyItems.getCount() / 2;
299 thread_db* tdbb = JRD_get_thread_data();
300
301 for (USHORT i = 0; i < count; i++)
302 {
303 const SortMap::Item* const item = &m_map->items[i];
304
305 const UCHAR flag1 = *(p + item->flagOffset);
306 const UCHAR flag2 = *(q + item->flagOffset);
307
308 if (flag1 != flag2)
309 return false;
310
311 if (!flag1)
312 {
313 dsc desc1 = item->desc;
314 desc1.dsc_address = const_cast<UCHAR*>(p) + (IPTR) desc1.dsc_address;
315
316 dsc desc2 = item->desc;
317 desc2.dsc_address = const_cast<UCHAR*>(q) + (IPTR) desc2.dsc_address;
318
319 if (MOV_compare(tdbb, &desc1, &desc2))
320 return false;
321 }
322 }
323
324 return true;
325}
326
327UCHAR* SortedStream::getData(thread_db* tdbb) const
328{

Callers 1

internalGetRecordMethod · 0.45

Calls 3

JRD_get_thread_dataFunction · 0.85
MOV_compareFunction · 0.85
getCountMethod · 0.45

Tested by

no test coverage detected