| 536 | // IndexKey class |
| 537 | |
| 538 | idx_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 | } |
no test coverage detected