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

Function BTR_key_length

src/jrd/btr.cpp:1600–1735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1598
1599
1600USHORT BTR_key_length(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
1601{
1602/**************************************
1603 *
1604 * B T R _ k e y _ l e n g t h
1605 *
1606 **************************************
1607 *
1608 * Functional description
1609 * Compute the maximum key length for an index.
1610 *
1611 **************************************/
1612 SET_TDBB(tdbb);
1613
1614 // hvlad: in ODS11 key of descending index can be prefixed with
1615 // one byte value. See comments in compress
1616 const SLONG prefix = (idx->idx_flags & idx_descending) ? 1 : 0;
1617
1618 const Format* format = MET_current(tdbb, relation);
1619 index_desc::idx_repeat* tail = idx->idx_rpt;
1620
1621 SLONG length;
1622
1623 // If there is only a single key, the computation is straightforward.
1624 if (idx->idx_count == 1)
1625 {
1626 switch (tail->idx_itype)
1627 {
1628 case idx_numeric:
1629 length = sizeof(double);
1630 break;
1631
1632 case idx_sql_time:
1633 case idx_sql_time_tz:
1634 length = sizeof(ULONG);
1635 break;
1636
1637 case idx_sql_date:
1638 length = sizeof(SLONG);
1639 break;
1640
1641 case idx_timestamp:
1642 case idx_timestamp_tz:
1643 length = sizeof(SINT64);
1644 break;
1645
1646 case idx_numeric2:
1647 length = INT64_KEY_LENGTH;
1648 break;
1649
1650 case idx_boolean:
1651 length = sizeof(UCHAR);
1652 break;
1653
1654 case idx_decimal:
1655 length = Decimal128::getIndexKeyLength();
1656 break;
1657

Callers 4

IDX_create_indexFunction · 0.85
insert_nodeFunction · 0.85
RetrievalMethod · 0.85
getNavigationMethod · 0.85

Calls 2

SET_TDBBFunction · 0.85
INTL_key_lengthFunction · 0.85

Tested by

no test coverage detected