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

Method compose

src/jrd/btr.cpp:538–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536// IndexKey class
537
538idx_e IndexKey::compose(Record* record)
539{
540 // Compute a key from a record and an index descriptor.
541 // Note that compound keys are expanded by 25%.
542 // If this changes, both BTR_key_length and GDEF exe.e have to change.
543
544 const auto dbb = m_tdbb->getDatabase();
545 const auto maxKeyLength = dbb->getMaxIndexKeyLength();
546
547 temporary_key temp;
548 temp.key_flags = 0;
549 temp.key_length = 0;
550
551 dsc desc;
552 dsc* desc_ptr;
553
554 auto tail = m_index->idx_rpt;
555 m_key.key_flags = 0;
556 m_key.key_nulls = 0;
557
558 const bool descending = (m_index->idx_flags & idx_descending);
559
560 try
561 {
562 if (m_index->idx_count == 1)
563 {
564 // For expression indices, compute the value of the expression
565
566 if (m_index->idx_flags & idx_expression)
567 {
568 if (!m_expression)
569 m_expression = FB_NEW_POOL(*m_tdbb->getDefaultPool()) IndexExpression(m_tdbb, m_index);
570
571 desc_ptr = m_expression->evaluate(record);
572 // Multi-byte text descriptor is returned already adjusted.
573 }
574 else
575 {
576 // In order to "map a null to a default" value (in EVL_field()),
577 // the relation block is referenced.
578 // Reference: Bug 10116, 10424
579
580 if (EVL_field(m_relation, record, tail->idx_field, &desc))
581 {
582 desc_ptr = &desc;
583
584 if (desc_ptr->dsc_dtype == dtype_text &&
585 tail->idx_field < record->getFormat()->fmt_desc.getCount())
586 {
587 // That's necessary for NO-PAD collations.
588 INTL_adjust_text_descriptor(m_tdbb, desc_ptr);
589 }
590 }
591 else
592 {
593 desc_ptr = nullptr;
594 }
595 }

Callers 9

handlerMethod · 0.45
handlerMethod · 0.45
IDX_garbage_collectFunction · 0.45
IDX_modifyFunction · 0.45
IDX_storeFunction · 0.45
check_partner_indexFunction · 0.45
lookupRecordMethod · 0.45
internalGetRecordMethod · 0.45

Calls 15

IndexExpressionClass · 0.85
EVL_fieldFunction · 0.85
compressFunction · 0.85
BTR_complement_keyFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
getDatabaseMethod · 0.80
getMaxIndexKeyLengthMethod · 0.80
getDefaultPoolMethod · 0.45
evaluateMethod · 0.45
getCountMethod · 0.45

Tested by

no test coverage detected