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

Function BTR_make_key

src/jrd/btr.cpp:1854–2030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1852
1853
1854idx_e BTR_make_key(thread_db* tdbb,
1855 USHORT count,
1856 const ValueExprNode* const* exprs,
1857 const SSHORT* scale,
1858 const index_desc* idx,
1859 temporary_key* key,
1860 USHORT keyType,
1861 bool* forceInclude)
1862{
1863/**************************************
1864 *
1865 * B T R _ m a k e _ k e y
1866 *
1867 **************************************
1868 *
1869 * Functional description
1870 * Construct a (possibly) compound search key given a key count,
1871 * a vector of value expressions, and a place to put the key.
1872 *
1873 **************************************/
1874 const auto dbb = tdbb->getDatabase();
1875 const auto request = tdbb->getRequest();
1876
1877 temporary_key temp;
1878 temp.key_flags = 0;
1879 temp.key_length = 0;
1880
1881 fb_assert(count > 0);
1882 fb_assert(idx != NULL);
1883 fb_assert(exprs != NULL);
1884 fb_assert(key != NULL);
1885
1886 key->key_flags = 0;
1887 key->key_nulls = 0;
1888
1889 const bool fuzzy = (keyType == INTL_KEY_PARTIAL || keyType == INTL_KEY_MULTI_STARTING);
1890 const bool descending = (idx->idx_flags & idx_descending);
1891
1892 const index_desc::idx_repeat* tail = idx->idx_rpt;
1893
1894 const USHORT maxKeyLength = dbb->getMaxIndexKeyLength();
1895
1896 // If the index is a single segment index, don't sweat the compound stuff
1897 if (idx->idx_count == 1)
1898 {
1899 const auto desc = EVL_expr(tdbb, request, *exprs);
1900
1901 if (!desc)
1902 key->key_nulls = 1;
1903
1904 key->key_flags |= key_empty;
1905
1906 compress(tdbb, desc, scale ? *scale : 0, key, tail->idx_itype, descending, keyType, forceInclude);
1907
1908 if (fuzzy && (key->key_flags & key_empty))
1909 {
1910 key->key_length = 0;
1911 key->key_next.reset();

Callers 2

makeKeysMethod · 0.85
BTR_make_boundsFunction · 0.85

Calls 10

EVL_exprFunction · 0.85
compressFunction · 0.85
BTR_complement_keyFunction · 0.85
getDatabaseMethod · 0.80
getMaxIndexKeyLengthMethod · 0.80
temporary_keyClass · 0.70
getRequestMethod · 0.45
resetMethod · 0.45
getMethod · 0.45
getDefaultPoolMethod · 0.45

Tested by

no test coverage detected