| 2031 | |
| 2032 | |
| 2033 | void BTR_make_null_key(thread_db* tdbb, const index_desc* idx, temporary_key* key) |
| 2034 | { |
| 2035 | /************************************** |
| 2036 | * |
| 2037 | * B T R _ m a k e _ n u l l _ k e y |
| 2038 | * |
| 2039 | ************************************** |
| 2040 | * |
| 2041 | * Functional description |
| 2042 | * Construct a (possibly) compound search key consist from |
| 2043 | * all null values. This is worked only for ODS11 and later |
| 2044 | * |
| 2045 | **************************************/ |
| 2046 | temporary_key temp; |
| 2047 | temp.key_flags = 0; |
| 2048 | temp.key_length = 0; |
| 2049 | |
| 2050 | SET_TDBB(tdbb); |
| 2051 | |
| 2052 | fb_assert(idx != NULL); |
| 2053 | fb_assert(key != NULL); |
| 2054 | |
| 2055 | key->key_flags = 0; |
| 2056 | key->key_nulls = (1 << idx->idx_count) - 1; |
| 2057 | |
| 2058 | const bool descending = (idx->idx_flags & idx_descending); |
| 2059 | |
| 2060 | const index_desc::idx_repeat* tail = idx->idx_rpt; |
| 2061 | |
| 2062 | // If the index is a single segment index, don't sweat the compound stuff |
| 2063 | if ((idx->idx_count == 1) || (idx->idx_flags & idx_expression)) |
| 2064 | { |
| 2065 | compress(tdbb, nullptr, 0, key, tail->idx_itype, descending, INTL_KEY_SORT, nullptr); |
| 2066 | } |
| 2067 | else |
| 2068 | { |
| 2069 | // Make a compound key |
| 2070 | UCHAR* p = key->key_data; |
| 2071 | SSHORT stuff_count = 0; |
| 2072 | temp.key_flags |= key_empty; |
| 2073 | |
| 2074 | for (USHORT n = 0; n < idx->idx_count; n++, tail++) |
| 2075 | { |
| 2076 | for (; stuff_count; --stuff_count) |
| 2077 | *p++ = 0; |
| 2078 | |
| 2079 | compress(tdbb, nullptr, 0, &temp, tail->idx_itype, descending, INTL_KEY_SORT, nullptr); |
| 2080 | |
| 2081 | const UCHAR* q = temp.key_data; |
| 2082 | for (USHORT l = temp.key_length; l; --l, --stuff_count) |
| 2083 | { |
| 2084 | if (stuff_count == 0) |
| 2085 | { |
| 2086 | *p++ = idx->idx_count - n; |
| 2087 | stuff_count = STUFF_COUNT; |
| 2088 | } |
| 2089 | *p++ = *q++; |
| 2090 | } |
no test coverage detected