| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2017, 2023, MariaDB Corporation. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it under |
| 7 | the terms of the GNU General Public License as published by the Free Software |
| 8 | Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along with |
| 15 | this program; if not, write to the Free Software Foundation, Inc., |
| 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | |
| 18 | *****************************************************************************/ |
| 19 | |
| 20 | /********************************************************************//** |
| 21 | @file include/rem0rec.ic |
| 22 | Record manager |
| 23 | |
| 24 | Created 5/30/1994 Heikki Tuuri |
| 25 | *************************************************************************/ |
| 26 | |
| 27 | #include "mach0data.h"cxx . . $ `<file>/storage/innobase/include/mach0data.h`/ |
| 28 | #include "ut0byte.h"cxx . . $ `<file>/storage/innobase/include/ut0byte.h`/ |
| 29 | #include "dict0boot.h"cxx . . $ `<file>/storage/innobase/include/dict0boot.h`/ |
| 30 | #include "btr0types.h"cxx . . $ `<file>/storage/innobase/include/btr0types.h`/ |
| 31 | |
| 32 | /* Offsets of the bit-fields in an old-style record. NOTE! In the table the |
| 33 | most significant bytes and bits are written below less significant. |
| 34 | |
| 35 | (1) byte offset (2) bit usage within byte |
| 36 | downward from |
| 37 | origin -> 1 8 bits pointer to next record |
| 38 | 2 8 bits pointer to next record |
| 39 | 3 1 bit short flag |
| 40 | 7 bits number of fields |
| 41 | 4 3 bits number of fields |
| 42 | 5 bits heap number |
| 43 | 5 8 bits heap number |
| 44 | 6 4 bits n_owned |
| 45 | 4 bits info bits |
| 46 | */ |
| 47 | |
| 48 | /* Offsets of the bit-fields in a new-style record. NOTE! In the table the |
| 49 | most significant bytes and bits are written below less significant. |
| 50 | |
| 51 | (1) byte offset (2) bit usage within byte |
| 52 | downward from |
| 53 | origin -> 1 8 bits relative offset of next record |
| 54 | 2 8 bits relative offset of next record |
| 55 | the relative offset is an unsigned 16-bit |
| 56 | integer: |
| 57 | (offset_of_next_record |
| 58 | - offset_of_this_record) mod 64Ki, |
| 59 | where mod is the modulo as a non-negative |
| 60 | number; |
| 61 | we can calculate the offset of the next |
| 62 | record with the formula: |
| 63 | relative_offset + offset_of_this_record |
| 64 | mod srv_page_size |
| 65 | 3 3 bits status: |
| 66 | 000=REC_STATUS_ORDINARY |
| 67 | 001=REC_STATUS_NODE_PTR |
| 68 | 010=REC_STATUS_INFIMUM |
| 69 | 011=REC_STATUS_SUPREMUM |
| 70 | 100=REC_STATUS_INSTANT |
| 71 | 1xx=reserved |
| 72 | 5 bits heap number |
| 73 | 4 8 bits heap number |
| 74 | 5 4 bits n_owned |
| 75 | 4 bits info bits |
| 76 | */ |
| 77 | |
| 78 | /* We list the byte offsets from the origin of the record, the mask, |
| 79 | and the shift needed to obtain each bit-field of the record. */ |
| 80 | |
| 81 | #define REC_NEXTcxx . . $ `storage/innobase/include/rem0rec.inl:81:9`! 2 |
| 82 | #define REC_NEXT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:82:9`! 0xFFFFUL |
| 83 | #define REC_NEXT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:83:9`! 0 |
| 84 | |
| 85 | #define REC_OLD_SHORTcxx . . $ `storage/innobase/include/rem0rec.inl:85:9`! 3 /* This is single byte bit-field */ |
| 86 | #define REC_OLD_SHORT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:86:9`! 0x1UL |
| 87 | #define REC_OLD_SHORT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:87:9`! 0 |
| 88 | |
| 89 | #define REC_OLD_N_FIELDScxx . . $ `storage/innobase/include/rem0rec.inl:89:9`! 4 |
| 90 | #define REC_OLD_N_FIELDS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:90:9`! 0x7FEUL |
| 91 | #define REC_OLD_N_FIELDS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:91:9`! 1 |
| 92 | |
| 93 | #define REC_OLD_HEAP_NOcxx . . $ `storage/innobase/include/rem0rec.inl:93:9`! 5 |
| 94 | #define REC_HEAP_NO_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:94:9`! 0xFFF8UL |
| 95 | #if 0 /* defined in rem0rec.h for use of page0zip.cc */ |
| 96 | #define REC_NEW_HEAP_NO 4 |
| 97 | #define REC_HEAP_NO_SHIFT 3 |
| 98 | #endif |
| 99 | |
| 100 | #define REC_OLD_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:100:9`! 6 /* This is single byte bit-field */ |
| 101 | #define REC_NEW_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:101:9`! 5 /* This is single byte bit-field */ |
| 102 | #define REC_N_OWNED_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:102:9`! 0xFUL |
| 103 | #define REC_N_OWNED_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:103:9`! 0 |
| 104 | |
| 105 | #define REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`! 6 /* This is single byte bit-field */ |
| 106 | #define REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`! 5 /* This is single byte bit-field */ |
| 107 | #define REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`! 0xF0UL |
| 108 | #define REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`! 0 |
| 109 | |
| 110 | #if REC_OLD_SHORT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:86:9`! << (8 * (REC_OLD_SHORTcxx . . $ `storage/innobase/include/rem0rec.inl:85:9`! - 3)) \ |
| 111 | ^ REC_OLD_N_FIELDS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:90:9`! << (8 * (REC_OLD_N_FIELDScxx . . $ `storage/innobase/include/rem0rec.inl:89:9`! - 4)) \ |
| 112 | ^ REC_HEAP_NO_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:94:9`! << (8 * (REC_OLD_HEAP_NOcxx . . $ `storage/innobase/include/rem0rec.inl:93:9`! - 4)) \ |
| 113 | ^ REC_N_OWNED_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:102:9`! << (8 * (REC_OLD_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:100:9`! - 3)) \ |
| 114 | ^ REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`! << (8 * (REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`! - 3)) \ |
| 115 | ^ 0xFFFFFFFFUL |
| 116 | # error "sum of old-style masks != 0xFFFFFFFFUL" |
| 117 | #endif |
| 118 | #if REC_NEW_STATUS_MASKcxx . . $ `storage/innobase/include/rem0rec.h:49:9`! << (8 * (REC_NEW_STATUScxx . . $ `storage/innobase/include/rem0rec.h:48:9`! - 3)) \ |
| 119 | ^ REC_HEAP_NO_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:94:9`! << (8 * (REC_NEW_HEAP_NOcxx . . $ `storage/innobase/include/rem0rec.h:56:9`! - 4)) \ |
| 120 | ^ REC_N_OWNED_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:102:9`! << (8 * (REC_NEW_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:101:9`! - 3)) \ |
| 121 | ^ REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`! << (8 * (REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`! - 3)) \ |
| 122 | ^ 0xFFFFFFUL |
| 123 | # error "sum of new-style masks != 0xFFFFFFUL" |
| 124 | #endif |
| 125 | |
| 126 | /******************************************************//** |
| 127 | Gets a bit field from within 1 byte. */ |
| 128 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 129 | bytecxx . . $ byte# |
| 130 | rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).( |
| 131 | /*================*/ |
| 132 | const rec_tcxx . . $ rec_t#* rec, /*!< in: pointer to record origin */ |
| 133 | ulintcxx . . $ ulint# offs, /*!< in: offset from the origin down */ |
| 134 | ulintcxx . . $ ulint# mask, /*!< in: mask used to filter bits */ |
| 135 | ulintcxx . . $ ulint# shift) /*!< in: shift right applied after masking */ |
| 136 | { |
| 137 | return static_cast<bytecxx . . $ byte#>((*(rec - offs) & mask) >> shift); |
| 138 | } |
| 139 | |
| 140 | /******************************************************//** |
| 141 | Sets a bit field within 1 byte. */ |
| 142 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 143 | void |
| 144 | rec_set_bit_field_1cxx . . $ rec_set_bit_field_1(f8392136b999870e).( |
| 145 | /*================*/ |
| 146 | rec_tcxx . . $ rec_t#* rec, /*!< in: pointer to record origin */ |
| 147 | ulintcxx . . $ ulint# val, /*!< in: value to set */ |
| 148 | ulintcxx . . $ ulint# offs, /*!< in: offset from the origin down */ |
| 149 | ulintcxx . . $ ulint# mask, /*!< in: mask used to filter bits */ |
| 150 | ulintcxx . . $ ulint# shift) /*!< in: shift right applied after masking */ |
| 151 | { |
| 152 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 153 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(offs <= REC_N_OLD_EXTRA_BYTES); |
| 154 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mask); |
| 155 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mask <= 0xFFUL); |
| 156 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(((mask >> shift) << shift) == mask); |
| 157 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(((val << shift) & mask) == (val << shift)); |
| 158 | |
| 159 | mach_write_to_1cxx . . $ mach_write_to_1(6165b45f45ef689c).(rec - offs, |
| 160 | (mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(rec - offs) & ~mask) |
| 161 | | (val << shift)); |
| 162 | } |
| 163 | |
| 164 | /******************************************************//** |
| 165 | Gets a bit field from within 2 bytes. */ |
| 166 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 167 | uint16_tcxx . . $ uint16_t# |
| 168 | rec_get_bit_field_2cxx . . $ rec_get_bit_field_2(c684f174dd0813c0).( |
| 169 | /*================*/ |
| 170 | const rec_tcxx . . $ rec_t#* rec, /*!< in: pointer to record origin */ |
| 171 | ulintcxx . . $ ulint# offs, /*!< in: offset from the origin down */ |
| 172 | ulintcxx . . $ ulint# mask, /*!< in: mask used to filter bits */ |
| 173 | ulintcxx . . $ ulint# shift) /*!< in: shift right applied after masking */ |
| 174 | { |
| 175 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 176 | |
| 177 | return uint16_tcxx . . $ uint16_t#((mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(rec - offs) & mask) >> shift); |
| 178 | } |
| 179 | |
| 180 | /******************************************************//** |
| 181 | Sets a bit field within 2 bytes. */ |
| 182 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 183 | void |
| 184 | rec_set_bit_field_2cxx . . $ rec_set_bit_field_2(f8392136b999870e).( |
| 185 | /*================*/ |
| 186 | rec_tcxx . . $ rec_t#* rec, /*!< in: pointer to record origin */ |
| 187 | ulintcxx . . $ ulint# val, /*!< in: value to set */ |
| 188 | ulintcxx . . $ ulint# offs, /*!< in: offset from the origin down */ |
| 189 | ulintcxx . . $ ulint# mask, /*!< in: mask used to filter bits */ |
| 190 | ulintcxx . . $ ulint# shift) /*!< in: shift right applied after masking */ |
| 191 | { |
| 192 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 193 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(offs <= REC_N_OLD_EXTRA_BYTES); |
| 194 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mask > 0xFFUL); |
| 195 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mask <= 0xFFFFUL); |
| 196 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((mask >> shift) & 1); |
| 197 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(0 == ((mask >> shift) & ((mask >> shift) + 1))); |
| 198 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(((mask >> shift) << shift) == mask); |
| 199 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(((val << shift) & mask) == (val << shift)); |
| 200 | |
| 201 | mach_write_to_2cxx . . $ mach_write_to_2(6165b45f45ef689c).(rec - offs, |
| 202 | (mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(rec - offs) & ~mask) |
| 203 | | (val << shift)); |
| 204 | } |
| 205 | |
| 206 | /******************************************************//** |
| 207 | The following function is used to get the offset of the next chained record |
| 208 | on the same page. |
| 209 | @return the page offset of the next chained record, or 0 if none */ |
| 210 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 211 | ulintcxx . . $ ulint# |
| 212 | rec_get_next_offscxx . . $ rec_get_next_offs(4adc7973d4c4f159).( |
| 213 | /*==============*/ |
| 214 | const rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 215 | ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page format */ |
| 216 | { |
| 217 | ulintcxx . . $ ulint# field_value; |
| 218 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(REC_NEXT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:82:9`! == 0xFFFFUL); |
| 219 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(REC_NEXT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:83:9`! == 0); |
| 220 | |
| 221 | field_value = mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(rec - REC_NEXTcxx . . $ `storage/innobase/include/rem0rec.inl:81:9`!); |
| 222 | |
| 223 | if (comp) { |
| 224 | #if UNIV_PAGE_SIZE_MAXcxx . . $ `storage/innobase/include/univ.i:214:9`! <= 32768 |
| 225 | /* Note that for 64 KiB pages, field_value can 'wrap around' |
| 226 | and the debug assertion is not valid */ |
| 227 | |
| 228 | /* In the following assertion, field_value is interpreted |
| 229 | as signed 16-bit integer in 2's complement arithmetics. |
| 230 | If all platforms defined int16_t in the standard headers, |
| 231 | the expression could be written simpler as |
| 232 | (int16_t) field_value + ut_align_offset(...) < srv_page_size |
| 233 | */ |
| 234 | ut_ad((field_value >= 32768 |
| 235 | ? field_value - 65536 |
| 236 | : field_value) |
| 237 | + ut_align_offset(rec, srv_page_size) |
| 238 | < srv_page_size); |
| 239 | #endif |
| 240 | if (field_value == 0) { |
| 241 | |
| 242 | return(0); |
| 243 | } |
| 244 | |
| 245 | /* There must be at least REC_N_NEW_EXTRA_BYTES + 1 |
| 246 | between each record. */ |
| 247 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((field_value > REC_N_NEW_EXTRA_BYTES |
| 248 | && field_value < 32768) |
| 249 | || field_value < (uint16) -REC_N_NEW_EXTRA_BYTES); |
| 250 | |
| 251 | return(ut_align_offsetcxx . . $ ut_align_offset(746566a4864dd891).(rec + field_value, srv_page_sizecxx . . $ srv_page_size.)); |
| 252 | } else { |
| 253 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(field_value < srv_page_size); |
| 254 | |
| 255 | return(field_value); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | /******************************************************//** |
| 260 | The following function is used to set the next record offset field |
| 261 | of an old-style record. */ |
| 262 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 263 | void |
| 264 | rec_set_next_offs_oldcxx . . $ rec_set_next_offs_old(6165b45f45ef689c).( |
| 265 | /*==================*/ |
| 266 | rec_tcxx . . $ rec_t#* rec, /*!< in: old-style physical record */ |
| 267 | ulintcxx . . $ ulint# next) /*!< in: offset of the next record */ |
| 268 | { |
| 269 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(srv_page_size > next); |
| 270 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(REC_NEXT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:82:9`! == 0xFFFFUL); |
| 271 | compile_time_assertcxx . . $ rec_set_next_offs_old(6165b45f45ef689c).compile_time_assert#(REC_NEXT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:83:9`! == 0); |
| 272 | mach_write_to_2cxx . . $ mach_write_to_2(6165b45f45ef689c).(rec - REC_NEXTcxx . . $ `storage/innobase/include/rem0rec.inl:81:9`!, next); |
| 273 | } |
| 274 | |
| 275 | /******************************************************//** |
| 276 | The following function is used to set the next record offset field |
| 277 | of a new-style record. */ |
| 278 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 279 | void |
| 280 | rec_set_next_offs_newcxx . . $ rec_set_next_offs_new(6165b45f45ef689c).( |
| 281 | /*==================*/ |
| 282 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: new-style physical record */ |
| 283 | ulintcxx . . $ ulint# next) /*!< in: offset of the next record */ |
| 284 | { |
| 285 | ulintcxx . . $ ulint# field_value; |
| 286 | |
| 287 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(srv_page_size > next); |
| 288 | |
| 289 | if (!next) { |
| 290 | field_value = 0; |
| 291 | } else { |
| 292 | /* The following two statements calculate |
| 293 | next - offset_of_rec mod 64Ki, where mod is the modulo |
| 294 | as a non-negative number */ |
| 295 | |
| 296 | field_value = (ulintcxx . . $ ulint#) |
| 297 | ((lintcxx . . $ lint#) next |
| 298 | - (lintcxx . . $ lint#) ut_align_offsetcxx . . $ ut_align_offset(746566a4864dd891).(rec, srv_page_sizecxx . . $ srv_page_size.)); |
| 299 | field_value &= REC_NEXT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:82:9`!; |
| 300 | } |
| 301 | |
| 302 | mach_write_to_2cxx . . $ mach_write_to_2(6165b45f45ef689c).(rec - REC_NEXTcxx . . $ `storage/innobase/include/rem0rec.inl:81:9`!, field_value); |
| 303 | } |
| 304 | |
| 305 | /******************************************************//** |
| 306 | The following function is used to get the number of fields |
| 307 | in an old-style record. |
| 308 | @return number of data fields */ |
| 309 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 310 | uint16_tcxx . . $ uint16_t# |
| 311 | rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).( |
| 312 | /*=================*/ |
| 313 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 314 | { |
| 315 | uint16_tcxx . . $ uint16_t# ret = rec_get_bit_field_2cxx . . $ rec_get_bit_field_2(c684f174dd0813c0).(rec, REC_OLD_N_FIELDScxx . . $ `storage/innobase/include/rem0rec.inl:89:9`!, |
| 316 | REC_OLD_N_FIELDS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:90:9`!, |
| 317 | REC_OLD_N_FIELDS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:91:9`!); |
| 318 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(ret <= REC_MAX_N_FIELDS); |
| 319 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(ret > 0); |
| 320 | |
| 321 | return(ret); |
| 322 | } |
| 323 | |
| 324 | /******************************************************//** |
| 325 | The following function is used to set the number of fields |
| 326 | in an old-style record. */ |
| 327 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 328 | void |
| 329 | rec_set_n_fields_oldcxx . . $ rec_set_n_fields_old(6165b45f45ef689c).( |
| 330 | /*=================*/ |
| 331 | rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 332 | ulintcxx . . $ ulint# n_fields) /*!< in: the number of fields */ |
| 333 | { |
| 334 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 335 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields <= REC_MAX_N_FIELDS); |
| 336 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields > 0); |
| 337 | |
| 338 | rec_set_bit_field_2cxx . . $ rec_set_bit_field_2(f8392136b999870e).(rec, n_fields, REC_OLD_N_FIELDScxx . . $ `storage/innobase/include/rem0rec.inl:89:9`!, |
| 339 | REC_OLD_N_FIELDS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:90:9`!, REC_OLD_N_FIELDS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:91:9`!); |
| 340 | } |
| 341 | |
| 342 | /******************************************************//** |
| 343 | The following function is used to get the number of fields |
| 344 | in a record. |
| 345 | @return number of data fields */ |
| 346 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 347 | ulintcxx . . $ ulint# |
| 348 | rec_get_n_fieldscxx . . $ rec_get_n_fields(343724db9aa3dd2b).( |
| 349 | /*=============*/ |
| 350 | const rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 351 | const dict_index_tcxx . . $ dict_index_t#* index) /*!< in: record descriptor */ |
| 352 | { |
| 353 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 354 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index); |
| 355 | |
| 356 | if (!dict_table_is_compcxx . . $ dict_index_t#table.(index->table)) { |
| 357 | return(rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec)); |
| 358 | } |
| 359 | |
| 360 | switch (rec_get_statuscxx . . $ rec_get_status(f593bf8bf3023f2).(rec)) { |
| 361 | case REC_STATUS_INSTANTcxx . . $ REC_STATUS_INSTANT.: |
| 362 | case REC_STATUS_ORDINARYcxx . . $ REC_STATUS_ORDINARY.: |
| 363 | return(dict_index_get_n_fieldscxx . . $ dict_index_get_n_fields(40995254b96f8651).(index)); |
| 364 | case REC_STATUS_NODE_PTRcxx . . $ REC_STATUS_NODE_PTR.: |
| 365 | return(dict_index_get_n_unique_in_treecxx . . $ dict_index_get_n_unique_in_tree(40995254b96f8651).(index) + 1); |
| 366 | case REC_STATUS_INFIMUMcxx . . $ REC_STATUS_INFIMUM.: |
| 367 | case REC_STATUS_SUPREMUMcxx . . $ REC_STATUS_SUPREMUM.: |
| 368 | return(1); |
| 369 | } |
| 370 | |
| 371 | ut_errorcxx . . $ `storage/innobase/include/ut0dbg.h:58:9`!; |
| 372 | return(ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!); |
| 373 | } |
| 374 | |
| 375 | /** Confirms the n_fields of the entry is sane with comparing the other |
| 376 | record in the same page specified |
| 377 | @param[in] index index |
| 378 | @param[in] rec record of the same page |
| 379 | @param[in] entry index entry |
| 380 | @return true if n_fields is sane */ |
| 381 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 382 | bool |
| 383 | rec_n_fields_is_sanecxx . . $ rec_n_fields_is_sane(4f1849962256e900).( |
| 384 | dict_index_tcxx . . $ dict_index_t#* index, |
| 385 | const rec_tcxx . . $ rec_t#* rec, |
| 386 | const dtuple_tcxx . . $ dtuple_t#* entry) |
| 387 | { |
| 388 | const ulintcxx . . $ ulint# n_fields = rec_get_n_fieldscxx . . $ rec_get_n_fields(343724db9aa3dd2b).(rec, index); |
| 389 | |
| 390 | return(n_fields == dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(entry) |
| 391 | || (index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).() |
| 392 | && n_fields >= index->n_core_fieldscxx . . $ dict_index_t#n_core_fields.) |
| 393 | /* a record for older SYS_INDEXES table |
| 394 | (missing merge_threshold column) is acceptable. */ |
| 395 | || (index->tablecxx . . $ dict_index_t#table.->idcxx . . $ dict_table_t#id. == DICT_INDEXES_IDcxx . . $ `storage/innobase/include/dict0boot.h:77:9`! |
| 396 | && n_fields + 1 == dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(entry))); |
| 397 | } |
| 398 | |
| 399 | /******************************************************//** |
| 400 | The following function is used to get the number of records owned by the |
| 401 | previous directory record. |
| 402 | @return number of owned records */ |
| 403 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 404 | ulintcxx . . $ ulint# |
| 405 | rec_get_n_owned_oldcxx . . $ rec_get_n_owned_old(b191ace3c5bffbd9).( |
| 406 | /*================*/ |
| 407 | const rec_tcxx . . $ rec_t#* rec) /*!< in: old-style physical record */ |
| 408 | { |
| 409 | return(rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).(rec, REC_OLD_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:100:9`!, |
| 410 | REC_N_OWNED_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:102:9`!, REC_N_OWNED_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:103:9`!)); |
| 411 | } |
| 412 | |
| 413 | /******************************************************//** |
| 414 | The following function is used to get the number of records owned by the |
| 415 | previous directory record. |
| 416 | @return number of owned records */ |
| 417 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 418 | ulintcxx . . $ ulint# |
| 419 | rec_get_n_owned_newcxx . . $ rec_get_n_owned_new(b191ace3c5bffbd9).( |
| 420 | /*================*/ |
| 421 | const rec_tcxx . . $ rec_t#* rec) /*!< in: new-style physical record */ |
| 422 | { |
| 423 | return(rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).(rec, REC_NEW_N_OWNEDcxx . . $ `storage/innobase/include/rem0rec.inl:101:9`!, |
| 424 | REC_N_OWNED_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:102:9`!, REC_N_OWNED_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:103:9`!)); |
| 425 | } |
| 426 | |
| 427 | /******************************************************//** |
| 428 | The following function is used to retrieve the info bits of a record. |
| 429 | @return info bits */ |
| 430 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 431 | bytecxx . . $ byte# |
| 432 | rec_get_info_bitscxx . . $ rec_get_info_bits(24af2a219f1a922e).( |
| 433 | /*==============*/ |
| 434 | const rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 435 | ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page format */ |
| 436 | { |
| 437 | return rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).( |
| 438 | rec, comp ? REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`! : REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`!, |
| 439 | REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`!, REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!); |
| 440 | } |
| 441 | |
| 442 | /******************************************************//** |
| 443 | The following function is used to retrieve the info and status |
| 444 | bits of a record. (Only compact records have status bits.) |
| 445 | @return info and status bits */ |
| 446 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 447 | bytecxx . . $ byte# |
| 448 | rec_get_info_and_status_bitscxx . . $ rec_get_info_and_status_bits(24af2a219f1a922e).( |
| 449 | /*=========================*/ |
| 450 | const rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 451 | ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page format */ |
| 452 | { |
| 453 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(!((REC_NEW_STATUS_MASKcxx . . $ `storage/innobase/include/rem0rec.h:49:9`! >> REC_NEW_STATUS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.h:50:9`!) |
| 454 | & (REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`! >> REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!))); |
| 455 | if (comp) |
| 456 | return static_cast<bytecxx . . $ byte#>(rec_get_info_bitscxx . . $ rec_get_info_bits(24af2a219f1a922e).(rec, TRUEcxx . . $ `include/my_global.h:476:9`!) | |
| 457 | rec_get_statuscxx . . $ rec_get_status(f593bf8bf3023f2).(rec)); |
| 458 | else |
| 459 | return rec_get_info_bitscxx . . $ rec_get_info_bits(24af2a219f1a922e).(rec, FALSEcxx . . $ `include/my_global.h:477:9`!); |
| 460 | } |
| 461 | /******************************************************//** |
| 462 | The following function is used to set the info and status |
| 463 | bits of a record. (Only compact records have status bits.) */ |
| 464 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 465 | void |
| 466 | rec_set_info_and_status_bitscxx . . $ rec_set_info_and_status_bits(6165b45f45ef689c).( |
| 467 | /*=========================*/ |
| 468 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: physical record */ |
| 469 | ulintcxx . . $ ulint# bits) /*!< in: info bits */ |
| 470 | { |
| 471 | compile_time_assertcxx . . $ rec_set_info_and_status_bits(6165b45f45ef689c).compile_time_assert#(!((REC_NEW_STATUS_MASKcxx . . $ `storage/innobase/include/rem0rec.h:49:9`! >> REC_NEW_STATUS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.h:50:9`!) |
| 472 | & (REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`! >> REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!))); |
| 473 | rec_set_statuscxx . . $ rec_set_status(11ed9289fbde79a4).(rec, bits & REC_NEW_STATUS_MASKcxx . . $ `storage/innobase/include/rem0rec.h:49:9`!); |
| 474 | rec_set_bit_field_1cxx . . $ rec_set_bit_field_1(f8392136b999870e).(rec, bits & ~REC_NEW_STATUS_MASKcxx . . $ `storage/innobase/include/rem0rec.h:49:9`!, |
| 475 | REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`!, |
| 476 | REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`!, REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!); |
| 477 | } |
| 478 | |
| 479 | /******************************************************//** |
| 480 | The following function tells if record is delete marked. |
| 481 | @return nonzero if delete marked */ |
| 482 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 483 | ulintcxx . . $ ulint# |
| 484 | rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).( |
| 485 | /*=================*/ |
| 486 | const rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 487 | ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page format */ |
| 488 | { |
| 489 | if (comp) { |
| 490 | return(rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).(rec, REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`!, |
| 491 | REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!, |
| 492 | REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!)); |
| 493 | } else { |
| 494 | return(rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).(rec, REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`!, |
| 495 | REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!, |
| 496 | REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`!)); |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /******************************************************//** |
| 501 | The following function tells if a new-style record is a node pointer. |
| 502 | @return TRUE if node pointer */ |
| 503 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 504 | bool |
| 505 | rec_get_node_ptr_flagcxx . . $ rec_get_node_ptr_flag(190063cf6fb4afb1).( |
| 506 | /*==================*/ |
| 507 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 508 | { |
| 509 | return(REC_STATUS_NODE_PTRcxx . . $ REC_STATUS_NODE_PTR. == rec_get_statuscxx . . $ rec_get_status(f593bf8bf3023f2).(rec)); |
| 510 | } |
| 511 | |
| 512 | /******************************************************//** |
| 513 | The following function is used to get the order number |
| 514 | of an old-style record in the heap of the index page. |
| 515 | @return heap order number */ |
| 516 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 517 | uint16_tcxx . . $ uint16_t# |
| 518 | rec_get_heap_no_oldcxx . . $ rec_get_heap_no_old(469dcb4e54b221a8).( |
| 519 | /*================*/ |
| 520 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 521 | { |
| 522 | return(rec_get_bit_field_2cxx . . $ rec_get_bit_field_2(c684f174dd0813c0).(rec, REC_OLD_HEAP_NOcxx . . $ `storage/innobase/include/rem0rec.inl:93:9`!, |
| 523 | REC_HEAP_NO_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:94:9`!, REC_HEAP_NO_SHIFTcxx . . $ `storage/innobase/include/rem0rec.h:59:9`!)); |
| 524 | } |
| 525 | |
| 526 | /******************************************************//** |
| 527 | The following function is used to get the order number |
| 528 | of a new-style record in the heap of the index page. |
| 529 | @return heap order number */ |
| 530 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 531 | uint16_tcxx . . $ uint16_t# |
| 532 | rec_get_heap_no_newcxx . . $ rec_get_heap_no_new(469dcb4e54b221a8).( |
| 533 | /*================*/ |
| 534 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 535 | { |
| 536 | return(rec_get_bit_field_2cxx . . $ rec_get_bit_field_2(c684f174dd0813c0).(rec, REC_NEW_HEAP_NOcxx . . $ `storage/innobase/include/rem0rec.h:56:9`!, |
| 537 | REC_HEAP_NO_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:94:9`!, REC_HEAP_NO_SHIFTcxx . . $ `storage/innobase/include/rem0rec.h:59:9`!)); |
| 538 | } |
| 539 | |
| 540 | /******************************************************//** |
| 541 | The following function is used to test whether the data offsets in the record |
| 542 | are stored in one-byte or two-byte format. |
| 543 | @return TRUE if 1-byte form */ |
| 544 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 545 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! |
| 546 | rec_get_1byte_offs_flagcxx . . $ rec_get_1byte_offs_flag(b191ace3c5bffbd9).( |
| 547 | /*====================*/ |
| 548 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 549 | { |
| 550 | return(rec_get_bit_field_1cxx . . $ rec_get_bit_field_1(6a1def8090551980).(rec, REC_OLD_SHORTcxx . . $ `storage/innobase/include/rem0rec.inl:85:9`!, REC_OLD_SHORT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:86:9`!, |
| 551 | REC_OLD_SHORT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:87:9`!)); |
| 552 | } |
| 553 | |
| 554 | /******************************************************//** |
| 555 | The following function is used to set the 1-byte offsets flag. */ |
| 556 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 557 | void |
| 558 | rec_set_1byte_offs_flagcxx . . $ rec_set_1byte_offs_flag(6165b45f45ef689c).( |
| 559 | /*====================*/ |
| 560 | rec_tcxx . . $ rec_t#* rec, /*!< in: physical record */ |
| 561 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! flag) /*!< in: TRUE if 1byte form */ |
| 562 | { |
| 563 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flag <= 1); |
| 564 | |
| 565 | rec_set_bit_field_1cxx . . $ rec_set_bit_field_1(f8392136b999870e).(rec, flag, REC_OLD_SHORTcxx . . $ `storage/innobase/include/rem0rec.inl:85:9`!, REC_OLD_SHORT_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:86:9`!, |
| 566 | REC_OLD_SHORT_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:87:9`!); |
| 567 | } |
| 568 | |
| 569 | /******************************************************//** |
| 570 | Returns the offset of nth field end if the record is stored in the 1-byte |
| 571 | offsets form. If the field is SQL null, the flag is ORed in the returned |
| 572 | value. |
| 573 | @return offset of the start of the field, SQL null flag ORed */ |
| 574 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 575 | uint8_tcxx . . $ uint8_t# |
| 576 | rec_1_get_field_end_infocxx . . $ rec_1_get_field_end_info(24af2a219f1a922e).( |
| 577 | /*=====================*/ |
| 578 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 579 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 580 | { |
| 581 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_1byte_offs_flag(rec)); |
| 582 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_get_n_fields_old(rec)); |
| 583 | |
| 584 | return(mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + n + 1))); |
| 585 | } |
| 586 | |
| 587 | /******************************************************//** |
| 588 | Returns the offset of nth field end if the record is stored in the 2-byte |
| 589 | offsets form. If the field is SQL null, the flag is ORed in the returned |
| 590 | value. |
| 591 | @return offset of the start of the field, SQL null flag and extern |
| 592 | storage flag ORed */ |
| 593 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 594 | uint16_tcxx . . $ uint16_t# |
| 595 | rec_2_get_field_end_infocxx . . $ rec_2_get_field_end_info(cbdda48327e67104).( |
| 596 | /*=====================*/ |
| 597 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 598 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 599 | { |
| 600 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_1byte_offs_flag(rec)); |
| 601 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_get_n_fields_old(rec)); |
| 602 | |
| 603 | return(mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + 2 * n + 2))); |
| 604 | } |
| 605 | |
| 606 | /******************************************************//** |
| 607 | Returns nonzero if the field is stored off-page. |
| 608 | @retval 0 if the field is stored in-page |
| 609 | @retval REC_2BYTE_EXTERN_MASK if the field is stored externally */ |
| 610 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 611 | ulintcxx . . $ ulint# |
| 612 | rec_2_is_field_externcxx . . $ rec_2_is_field_extern(4adc7973d4c4f159).( |
| 613 | /*==================*/ |
| 614 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 615 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 616 | { |
| 617 | return(rec_2_get_field_end_infocxx . . $ rec_2_get_field_end_info(cbdda48327e67104).(rec, n) & REC_2BYTE_EXTERN_MASKcxx . . $ REC_2BYTE_EXTERN_MASK.); |
| 618 | } |
| 619 | |
| 620 | /**********************************************************//** |
| 621 | The following function sets the number of allocated elements |
| 622 | for an array of offsets. */ |
| 623 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 624 | void |
| 625 | rec_offs_set_n_alloccxx . . $ rec_offs_set_n_alloc(8bf1e866729cde2b).( |
| 626 | /*=================*/ |
| 627 | rec_offscxx . . $ rec_offs#*offsets, /*!< out: array for rec_get_offsets(), |
| 628 | must be allocated */ |
| 629 | ulintcxx . . $ ulint# n_alloc) /*!< in: number of elements */ |
| 630 | { |
| 631 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_alloc > REC_OFFS_HEADER_SIZE); |
| 632 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(offsets, n_alloc * sizeof *offsets); |
| 633 | offsets[0] = static_cast<rec_offscxx . . $ rec_offs#>(n_alloc); |
| 634 | } |
| 635 | |
| 636 | /************************************************************//** |
| 637 | The following function is used to get an offset to the nth |
| 638 | data field in a record. |
| 639 | @return offset from the origin of rec */ |
| 640 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 641 | rec_offscxx . . $ rec_offs# |
| 642 | rec_get_nth_field_offscxx . . $ rec_get_nth_field_offs(70b61031fb25acea).( |
| 643 | /*===================*/ |
| 644 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 645 | ulintcxx . . $ ulint# n, /*!< in: index of the field */ |
| 646 | ulintcxx . . $ ulint#* len) /*!< out: length of the field; UNIV_SQL_NULL |
| 647 | if SQL null; UNIV_SQL_DEFAULT is default value */ |
| 648 | { |
| 649 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_offs_n_fields(offsets)); |
| 650 | |
| 651 | rec_offscxx . . $ rec_offs# offs = n == 0 ? 0 : get_valuecxx . . $ get_value(a18c05e4017afb3d).(rec_offs_basecxx . . $ REC_OFFS_HEADER_SIZE.(offsets)[n]); |
| 652 | rec_offscxx . . $ rec_offs# next_offs = rec_offs_basecxx . . $ `storage/innobase/include/rem0rec.h:100:9`!(offsets)[1 + n]; |
| 653 | |
| 654 | if (get_typecxx . . $ get_type(8d0f7c9af0f57281).(next_offs) == SQL_NULLcxx . . $ SQL_NULL.) { |
| 655 | *len = UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!; |
| 656 | } else if (get_typecxx . . $ get_type(8d0f7c9af0f57281).(next_offs) == DEFAULTcxx . . $ DEFAULT.) { |
| 657 | *len = UNIV_SQL_DEFAULTcxx . . $ `storage/innobase/include/data0type.h:31:9`!; |
| 658 | } else { |
| 659 | *len = get_valuecxx . . $ get_value(a18c05e4017afb3d).(next_offs) - offs; |
| 660 | } |
| 661 | |
| 662 | return(offs); |
| 663 | } |
| 664 | |
| 665 | /******************************************************//** |
| 666 | Determine if the offsets are for a record containing null BLOB pointers. |
| 667 | @return first field containing a null BLOB pointer, or NULL if none found */ |
| 668 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 669 | const bytecxx . . $ byte#* |
| 670 | rec_offs_any_null_externcxx . . $ rec_offs_any_null_extern(906293a201ba1dcd).( |
| 671 | /*=====================*/ |
| 672 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 673 | const rec_offscxx . . $ rec_offs#* offsets) /*!< in: rec_get_offsets(rec) */ |
| 674 | { |
| 675 | ulintcxx . . $ ulint# i; |
| 676 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, NULL, offsets)); |
| 677 | |
| 678 | if (!rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets)) { |
| 679 | return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 680 | } |
| 681 | |
| 682 | for (i = 0; i < rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); i++) { |
| 683 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i)) { |
| 684 | ulintcxx . . $ ulint# len; |
| 685 | const bytecxx . . $ byte#* field |
| 686 | = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, i, &len); |
| 687 | |
| 688 | ut_acxx . . $ ulint#(len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 689 | if (!memcmp(field + len |
| 690 | - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!, |
| 691 | field_ref_zerocxx . . $ field_ref_zero., |
| 692 | BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!)) { |
| 693 | return(field); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 699 | } |
| 700 | |
| 701 | /******************************************************//** |
| 702 | Gets the physical size of a field. |
| 703 | @return length of field */ |
| 704 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 705 | ulintcxx . . $ ulint# |
| 706 | rec_offs_nth_sizecxx . . $ rec_offs_nth_size(878e7dc5509530f1).( |
| 707 | /*==============*/ |
| 708 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 709 | ulintcxx . . $ ulint# n) /*!< in: nth field */ |
| 710 | { |
| 711 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(NULL, NULL, offsets)); |
| 712 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_offs_n_fields(offsets)); |
| 713 | if (!n) { |
| 714 | return get_valuecxx . . $ get_value(a18c05e4017afb3d).(rec_offs_basecxx . . $ `storage/innobase/include/rem0rec.h:100:9`!(offsets)[1 + n]); |
| 715 | } |
| 716 | return get_valuecxx . . $ get_value(a18c05e4017afb3d).((rec_offs_basecxx . . $ `storage/innobase/include/rem0rec.h:100:9`!(offsets)[1 + n])) |
| 717 | - get_valuecxx . . $ get_value(a18c05e4017afb3d).(rec_offs_basecxx . . $ REC_OFFS_HEADER_SIZE.(offsets)[n]); |
| 718 | } |
| 719 | |
| 720 | /******************************************************//** |
| 721 | Returns the number of extern bits set in a record. |
| 722 | @return number of externally stored fields */ |
| 723 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 724 | ulintcxx . . $ ulint# |
| 725 | rec_offs_n_externcxx . . $ rec_offs_n_extern(6fce5c29061b60f9).( |
| 726 | /*==============*/ |
| 727 | const rec_offscxx . . $ rec_offs#* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 728 | { |
| 729 | ulintcxx . . $ ulint# n = 0; |
| 730 | |
| 731 | if (rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets)) { |
| 732 | ulintcxx . . $ ulint# i; |
| 733 | |
| 734 | for (i = rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); i--; ) { |
| 735 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i)) { |
| 736 | n++; |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | return(n); |
| 742 | } |
| 743 | |
| 744 | /******************************************************//** |
| 745 | Returns the offset of n - 1th field end if the record is stored in the 1-byte |
| 746 | offsets form. If the field is SQL null, the flag is ORed in the returned |
| 747 | value. This function and the 2-byte counterpart are defined here because the |
| 748 | C-compiler was not able to sum negative and positive constant offsets, and |
| 749 | warned of constant arithmetic overflow within the compiler. |
| 750 | @return offset of the start of the PREVIOUS field, SQL null flag ORed */ |
| 751 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 752 | ulintcxx . . $ ulint# |
| 753 | rec_1_get_prev_field_end_infocxx . . $ rec_1_get_prev_field_end_info(4adc7973d4c4f159).( |
| 754 | /*==========================*/ |
| 755 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 756 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 757 | { |
| 758 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_1byte_offs_flag(rec)); |
| 759 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n <= rec_get_n_fields_old(rec)); |
| 760 | |
| 761 | return(mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + n))); |
| 762 | } |
| 763 | |
| 764 | /******************************************************//** |
| 765 | Returns the offset of n - 1th field end if the record is stored in the 2-byte |
| 766 | offsets form. If the field is SQL null, the flag is ORed in the returned |
| 767 | value. |
| 768 | @return offset of the start of the PREVIOUS field, SQL null flag ORed */ |
| 769 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 770 | ulintcxx . . $ ulint# |
| 771 | rec_2_get_prev_field_end_infocxx . . $ rec_2_get_prev_field_end_info(4adc7973d4c4f159).( |
| 772 | /*==========================*/ |
| 773 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 774 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 775 | { |
| 776 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_1byte_offs_flag(rec)); |
| 777 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n <= rec_get_n_fields_old(rec)); |
| 778 | |
| 779 | return(mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + 2 * n))); |
| 780 | } |
| 781 | |
| 782 | /******************************************************//** |
| 783 | Sets the field end info for the nth field if the record is stored in the |
| 784 | 1-byte format. */ |
| 785 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 786 | void |
| 787 | rec_1_set_field_end_infocxx . . $ rec_1_set_field_end_info(73a68661ce58eed2).( |
| 788 | /*=====================*/ |
| 789 | rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 790 | ulintcxx . . $ ulint# n, /*!< in: field index */ |
| 791 | ulintcxx . . $ ulint# info) /*!< in: value to set */ |
| 792 | { |
| 793 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_1byte_offs_flag(rec)); |
| 794 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_get_n_fields_old(rec)); |
| 795 | |
| 796 | mach_write_to_1cxx . . $ mach_write_to_1(6165b45f45ef689c).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + n + 1), info); |
| 797 | } |
| 798 | |
| 799 | /******************************************************//** |
| 800 | Sets the field end info for the nth field if the record is stored in the |
| 801 | 2-byte format. */ |
| 802 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 803 | void |
| 804 | rec_2_set_field_end_infocxx . . $ rec_2_set_field_end_info(73a68661ce58eed2).( |
| 805 | /*=====================*/ |
| 806 | rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 807 | ulintcxx . . $ ulint# n, /*!< in: field index */ |
| 808 | ulintcxx . . $ ulint# info) /*!< in: value to set */ |
| 809 | { |
| 810 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_1byte_offs_flag(rec)); |
| 811 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n < rec_get_n_fields_old(rec)); |
| 812 | |
| 813 | mach_write_to_2cxx . . $ mach_write_to_2(6165b45f45ef689c).(rec - (REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + 2 * n + 2), info); |
| 814 | } |
| 815 | |
| 816 | /******************************************************//** |
| 817 | Returns the offset of nth field start if the record is stored in the 1-byte |
| 818 | offsets form. |
| 819 | @return offset of the start of the field */ |
| 820 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 821 | ulintcxx . . $ ulint# |
| 822 | rec_1_get_field_start_offscxx . . $ rec_1_get_field_start_offs(4adc7973d4c4f159).( |
| 823 | /*=======================*/ |
| 824 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 825 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 826 | { |
| 827 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_1byte_offs_flag(rec)); |
| 828 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n <= rec_get_n_fields_old(rec)); |
| 829 | |
| 830 | if (n == 0) { |
| 831 | |
| 832 | return(0); |
| 833 | } |
| 834 | |
| 835 | return(rec_1_get_prev_field_end_infocxx . . $ rec_1_get_prev_field_end_info(4adc7973d4c4f159).(rec, n) |
| 836 | & ~REC_1BYTE_SQL_NULL_MASKcxx . . $ REC_1BYTE_SQL_NULL_MASK.); |
| 837 | } |
| 838 | |
| 839 | /******************************************************//** |
| 840 | Returns the offset of nth field start if the record is stored in the 2-byte |
| 841 | offsets form. |
| 842 | @return offset of the start of the field */ |
| 843 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 844 | ulintcxx . . $ ulint# |
| 845 | rec_2_get_field_start_offscxx . . $ rec_2_get_field_start_offs(4adc7973d4c4f159).( |
| 846 | /*=======================*/ |
| 847 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 848 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 849 | { |
| 850 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_1byte_offs_flag(rec)); |
| 851 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n <= rec_get_n_fields_old(rec)); |
| 852 | |
| 853 | if (n == 0) { |
| 854 | |
| 855 | return(0); |
| 856 | } |
| 857 | |
| 858 | return(rec_2_get_prev_field_end_infocxx . . $ rec_2_get_prev_field_end_info(4adc7973d4c4f159).(rec, n) |
| 859 | & ~(REC_2BYTE_SQL_NULL_MASKcxx . . $ REC_2BYTE_SQL_NULL_MASK. | REC_2BYTE_EXTERN_MASKcxx . . $ REC_2BYTE_EXTERN_MASK.)); |
| 860 | } |
| 861 | |
| 862 | /******************************************************//** |
| 863 | The following function is used to read the offset of the start of a data field |
| 864 | in the record. The start of an SQL null field is the end offset of the |
| 865 | previous non-null field, or 0, if none exists. If n is the number of the last |
| 866 | field + 1, then the end offset of the last field is returned. |
| 867 | @return offset of the start of the field */ |
| 868 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 869 | ulintcxx . . $ ulint# |
| 870 | rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).( |
| 871 | /*=====================*/ |
| 872 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 873 | ulintcxx . . $ ulint# n) /*!< in: field index */ |
| 874 | { |
| 875 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 876 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n <= rec_get_n_fields_old(rec)); |
| 877 | |
| 878 | if (n == 0) { |
| 879 | |
| 880 | return(0); |
| 881 | } |
| 882 | |
| 883 | if (rec_get_1byte_offs_flagcxx . . $ rec_get_1byte_offs_flag(b191ace3c5bffbd9).(rec)) { |
| 884 | |
| 885 | return(rec_1_get_field_start_offscxx . . $ rec_1_get_field_start_offs(4adc7973d4c4f159).(rec, n)); |
| 886 | } |
| 887 | |
| 888 | return(rec_2_get_field_start_offscxx . . $ rec_2_get_field_start_offs(4adc7973d4c4f159).(rec, n)); |
| 889 | } |
| 890 | |
| 891 | /************************************************************//** |
| 892 | Gets the physical size of an old-style field. |
| 893 | Also an SQL null may have a field of size > 0, |
| 894 | if the data type is of a fixed size. |
| 895 | @return field size in bytes */ |
| 896 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 897 | ulintcxx . . $ ulint# |
| 898 | rec_get_nth_field_sizecxx . . $ rec_get_nth_field_size(4adc7973d4c4f159).( |
| 899 | /*===================*/ |
| 900 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 901 | ulintcxx . . $ ulint# n) /*!< in: index of the field */ |
| 902 | { |
| 903 | ulintcxx . . $ ulint# os; |
| 904 | ulintcxx . . $ ulint# next_os; |
| 905 | |
| 906 | os = rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, n); |
| 907 | next_os = rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, n + 1); |
| 908 | |
| 909 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(next_os - os < srv_page_size); |
| 910 | |
| 911 | return(next_os - os); |
| 912 | } |
| 913 | |
| 914 | /**********************************************************//** |
| 915 | The following function returns the data size of an old-style physical |
| 916 | record, that is the sum of field lengths. SQL null fields |
| 917 | are counted as length 0 fields. The value returned by the function |
| 918 | is the distance from record origin to record end in bytes. |
| 919 | @return size */ |
| 920 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 921 | ulintcxx . . $ ulint# |
| 922 | rec_get_data_size_oldcxx . . $ rec_get_data_size_old(b191ace3c5bffbd9).( |
| 923 | /*==================*/ |
| 924 | const rec_tcxx . . $ rec_t#* rec) /*!< in: physical record */ |
| 925 | { |
| 926 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 927 | |
| 928 | return(rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec))); |
| 929 | } |
| 930 | |
| 931 | /**********************************************************//** |
| 932 | The following function sets the number of fields in offsets. */ |
| 933 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 934 | void |
| 935 | rec_offs_set_n_fieldscxx . . $ rec_offs_set_n_fields(8bf1e866729cde2b).( |
| 936 | /*==================*/ |
| 937 | rec_offscxx . . $ rec_offs#* offsets, /*!< in/out: array returned by |
| 938 | rec_get_offsets() */ |
| 939 | ulintcxx . . $ ulint# n_fields) /*!< in: number of fields */ |
| 940 | { |
| 941 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(offsets); |
| 942 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields > 0); |
| 943 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields <= REC_MAX_N_FIELDS); |
| 944 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields + REC_OFFS_HEADER_SIZE |
| 945 | <= rec_offs_get_n_alloc(offsets)); |
| 946 | offsets[1] = static_cast<rec_offscxx . . $ rec_offs#>(n_fields); |
| 947 | } |
| 948 | |
| 949 | /**********************************************************//** |
| 950 | The following function returns the data size of a physical |
| 951 | record, that is the sum of field lengths. SQL null fields |
| 952 | are counted as length 0 fields. The value returned by the function |
| 953 | is the distance from record origin to record end in bytes. |
| 954 | @return size */ |
| 955 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 956 | ulintcxx . . $ ulint# |
| 957 | rec_offs_data_sizecxx . . $ rec_offs_data_size(6fce5c29061b60f9).( |
| 958 | /*===============*/ |
| 959 | const rec_offscxx . . $ rec_offs#* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 960 | { |
| 961 | ulintcxx . . $ ulint# size; |
| 962 | |
| 963 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(NULL, NULL, offsets)); |
| 964 | size = get_valuecxx . . $ get_value(a18c05e4017afb3d).(rec_offs_basecxx . . $ `storage/innobase/include/rem0rec.h:100:9`!(offsets)[rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets)]); |
| 965 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(size < srv_page_size); |
| 966 | return(size); |
| 967 | } |
| 968 | |
| 969 | /**********************************************************//** |
| 970 | Returns the total size of record minus data size of record. The value |
| 971 | returned by the function is the distance from record start to record origin |
| 972 | in bytes. |
| 973 | @return size */ |
| 974 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 975 | ulintcxx . . $ ulint# |
| 976 | rec_offs_extra_sizecxx . . $ rec_offs_extra_size(6fce5c29061b60f9).( |
| 977 | /*================*/ |
| 978 | const rec_offscxx . . $ rec_offs#* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 979 | { |
| 980 | ulintcxx . . $ ulint# size; |
| 981 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(NULL, NULL, offsets)); |
| 982 | size = *rec_offs_basecxx . . $ `storage/innobase/include/rem0rec.h:100:9`!(offsets) & REC_OFFS_MASKcxx . . $ REC_OFFS_MASK.; |
| 983 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(size < srv_page_size); |
| 984 | return(size); |
| 985 | } |
| 986 | |
| 987 | /**********************************************************//** |
| 988 | Returns the total size of a physical record. |
| 989 | @return size */ |
| 990 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 991 | ulintcxx . . $ ulint# |
| 992 | rec_offs_sizecxx . . $ rec_offs_size(6fce5c29061b60f9).( |
| 993 | /*==========*/ |
| 994 | const rec_offscxx . . $ rec_offs#* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 995 | { |
| 996 | return(rec_offs_data_sizecxx . . $ rec_offs_data_size(6fce5c29061b60f9).(offsets) + rec_offs_extra_sizecxx . . $ rec_offs_extra_size(6fce5c29061b60f9).(offsets)); |
| 997 | } |
| 998 | |
| 999 | #ifdef UNIV_DEBUG |
| 1000 | /**********************************************************//** |
| 1001 | Returns a pointer to the end of the record. |
| 1002 | @return pointer to end */ |
| 1003 | UNIV_INLINE |
| 1004 | byte* |
| 1005 | rec_get_end( |
| 1006 | /*========*/ |
| 1007 | const rec_t* rec, /*!< in: pointer to record */ |
| 1008 | const rec_offs* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 1009 | { |
| 1010 | ut_ad(rec_offs_validate(rec, NULL, offsets)); |
| 1011 | return(const_cast<rec_t*>(rec + rec_offs_data_size(offsets))); |
| 1012 | } |
| 1013 | |
| 1014 | /**********************************************************//** |
| 1015 | Returns a pointer to the start of the record. |
| 1016 | @return pointer to start */ |
| 1017 | UNIV_INLINE |
| 1018 | byte* |
| 1019 | rec_get_start( |
| 1020 | /*==========*/ |
| 1021 | const rec_t* rec, /*!< in: pointer to record */ |
| 1022 | const rec_offs* offsets)/*!< in: array returned by rec_get_offsets() */ |
| 1023 | { |
| 1024 | ut_ad(rec_offs_validate(rec, NULL, offsets)); |
| 1025 | return(const_cast<rec_t*>(rec - rec_offs_extra_size(offsets))); |
| 1026 | } |
| 1027 | #endif /* UNIV_DEBUG */ |
| 1028 | |
| 1029 | /** Copy a physical record to a buffer. |
| 1030 | @param[in] buf buffer |
| 1031 | @param[in] rec physical record |
| 1032 | @param[in] offsets array returned by rec_get_offsets() |
| 1033 | @return pointer to the origin of the copy */ |
| 1034 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 1035 | rec_tcxx . . $ rec_t#* |
| 1036 | rec_copycxx . . $ rec_copy(2ec1b33954fedb8b).( |
| 1037 | void* buf, |
| 1038 | const rec_tcxx . . $ rec_t#* rec, |
| 1039 | const rec_offscxx . . $ rec_offs#* offsets) |
| 1040 | { |
| 1041 | ulintcxx . . $ ulint# extra_len; |
| 1042 | ulintcxx . . $ ulint# data_len; |
| 1043 | |
| 1044 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec != NULL); |
| 1045 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(buf != NULL); |
| 1046 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, NULL, offsets)); |
| 1047 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_validate(rec, offsets)); |
| 1048 | |
| 1049 | extra_len = rec_offs_extra_sizecxx . . $ rec_offs_extra_size(6fce5c29061b60f9).(offsets); |
| 1050 | data_len = rec_offs_data_sizecxx . . $ rec_offs_data_size(6fce5c29061b60f9).(offsets); |
| 1051 | |
| 1052 | memcpy(buf, rec - extra_len, extra_len + data_len); |
| 1053 | |
| 1054 | return((bytecxx . . $ byte#*) buf + extra_len); |
| 1055 | } |
| 1056 | |
| 1057 | /**********************************************************//** |
| 1058 | Returns the extra size of an old-style physical record if we know its |
| 1059 | data size and number of fields. |
| 1060 | @return extra size */ |
| 1061 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 1062 | ulintcxx . . $ ulint# |
| 1063 | rec_get_converted_extra_sizecxx . . $ rec_get_converted_extra_size(315873a0897e1da0).( |
| 1064 | /*=========================*/ |
| 1065 | ulintcxx . . $ ulint# data_size, /*!< in: data size */ |
| 1066 | ulintcxx . . $ ulint# n_fields, /*!< in: number of fields */ |
| 1067 | ulintcxx . . $ ulint# n_ext) /*!< in: number of externally stored columns */ |
| 1068 | { |
| 1069 | if (!n_ext && data_size <= REC_1BYTE_OFFS_LIMITcxx . . $ `storage/innobase/include/rem0rec.h:1250:9`!) { |
| 1070 | |
| 1071 | return(REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + n_fields); |
| 1072 | } |
| 1073 | |
| 1074 | return(REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! + 2 * n_fields); |
| 1075 | } |
| 1076 | |
| 1077 | /**********************************************************//** |
| 1078 | The following function returns the size of a data tuple when converted to |
| 1079 | a physical record. |
| 1080 | @return size */ |
| 1081 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! |
| 1082 | ulintcxx . . $ ulint# |
| 1083 | rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).( |
| 1084 | /*===================*/ |
| 1085 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: record descriptor */ |
| 1086 | const dtuple_tcxx . . $ dtuple_t#* dtuple, /*!< in: data tuple */ |
| 1087 | ulintcxx . . $ ulint# n_ext) /*!< in: number of externally stored columns */ |
| 1088 | { |
| 1089 | ulintcxx . . $ ulint# data_size; |
| 1090 | ulintcxx . . $ ulint# extra_size; |
| 1091 | |
| 1092 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(dtuple)); |
| 1093 | #ifdef UNIV_DEBUG |
| 1094 | if ((dtuple_get_info_bits(dtuple) & REC_NEW_STATUS_MASK) |
| 1095 | == REC_STATUS_NODE_PTR) { |
| 1096 | ut_ad(dtuple->n_fields - 1 |
| 1097 | == dict_index_get_n_unique_in_tree_nonleaf(index)); |
| 1098 | } else if (index->table->id == DICT_INDEXES_ID) { |
| 1099 | /* The column SYS_INDEXES.MERGE_THRESHOLD was |
| 1100 | instantly added in MariaDB 10.2.2 (MySQL 5.7). */ |
| 1101 | ut_ad(!index->table->is_temporary()); |
| 1102 | ut_ad(index->n_fields == DICT_NUM_FIELDS__SYS_INDEXES); |
| 1103 | ut_ad(dtuple->n_fields == DICT_NUM_FIELDS__SYS_INDEXES |
| 1104 | || dtuple->n_fields |
| 1105 | == DICT_FLD__SYS_INDEXES__MERGE_THRESHOLD); |
| 1106 | } else { |
| 1107 | ut_ad(dtuple->n_fields >= index->n_core_fields); |
| 1108 | ut_ad(dtuple->n_fields <= index->n_fields |
| 1109 | || dtuple->is_alter_metadata()); |
| 1110 | } |
| 1111 | #endif |
| 1112 | |
| 1113 | if (dict_table_is_compcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).(index->table)) { |
| 1114 | return rec_get_converted_size_compcxx . . $ rec_get_converted_size_comp(38e7d996cd0ca223).(index, dtuple, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 1115 | } |
| 1116 | |
| 1117 | data_size = dtuple_get_data_sizecxx . . $ dtuple_get_data_size(dd3ffa519e5d98cd).(dtuple, 0); |
| 1118 | |
| 1119 | /* If primary key is being updated then the new record inherits |
| 1120 | externally stored fields from the delete-marked old record. |
| 1121 | In that case, n_ext may be less value than |
| 1122 | dtuple_get_n_ext(tuple). */ |
| 1123 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_ext <= dtuple_get_n_ext(dtuple)); |
| 1124 | extra_size = rec_get_converted_extra_sizecxx . . $ rec_get_converted_extra_size(315873a0897e1da0).( |
| 1125 | data_size, dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(dtuple), n_ext); |
| 1126 | |
| 1127 | return(data_size + extra_size); |
| 1128 | } |