Debian Codegraph @

storage/innobase/include/page0page.inl

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2016, 2022, 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/page0page.ic
22 Index page routines
23
24 Created 2/2/1994 Heikki Tuuri
25 *******************************************************/
26
27 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
28 #include "rem0cmp.h"cxx . . $ `<file>/storage/innobase/include/rem0cmp.h`/
29 #include "mtr0log.h"cxx . . $ `<file>/storage/innobase/include/mtr0log.h`/
30 #include "page0zip.h"cxx . . $ `<file>/storage/innobase/include/page0zip.h`/
31
32 /*************************************************************//**
33 Sets the max trx id field value if trx_id is bigger than the previous
34 value. */
35 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
36 void
37 page_update_max_trx_idcxx . . $ page_update_max_trx_id(7ff4fec4cd653b55).(
38 /*===================*/
39 buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: page */
40 page_zip_des_tcxx . . $ page_zip_des_t#* page_zip,/*!< in/out: compressed page whose
41 uncompressed part will be updated, or NULL */
42 trx_id_tcxx . . $ trx_id_t# trx_id, /*!< in: transaction id */
43 mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */
44 {
45 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block);
46 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
47 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id);
48 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(buf_block_get_frame(block)));
49
50 if (page_get_max_trx_idcxx . . $ page_get_max_trx_id(b191ace3c5bffbd9).(buf_block_get_framecxx . . $ buf_block_t#page.(block)) < trx_id) {
51
52 page_set_max_trx_idcxx . . $ page_set_max_trx_id(7ff4fec4cd653b55).(block, page_zip, trx_id, mtr);
53 }
54 }
55
56 /*************************************************************//**
57 Returns the RTREE SPLIT SEQUENCE NUMBER (FIL_RTREE_SPLIT_SEQ_NUM).
58 @return SPLIT SEQUENCE NUMBER */
59 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
60 node_seq_tcxx . . $ node_seq_t#
61 page_get_ssn_idcxx . . $ page_get_ssn_id(ca1608e2c87725e2).(
62 /*============*/
63 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page) /*!< in: page */
64 {
65 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page);
66
67 return(static_cast<node_seq_tcxx . . $ node_seq_t#>(
68 mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(page + FIL_RTREE_SPLIT_SEQ_NUMcxx . . $ `storage/innobase/include/fil0fil.h:1239:9`!)));
69 }
70
71 /*************************************************************//**
72 Sets the RTREE SPLIT SEQUENCE NUMBER field value */
73 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
74 void
75 page_set_ssn_idcxx . . $ page_set_ssn_id(7abb3fcdde7580e1).(
76 /*============*/
77 buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: page */
78 page_zip_des_tcxx . . $ page_zip_des_t#* page_zip,/*!< in/out: compressed page whose
79 uncompressed part will be updated, or NULL */
80 node_seq_tcxx . . $ node_seq_t# ssn_id, /*!< in: transaction id */
81 mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */
82 {
83 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_SX_FIX |
84 MTR_MEMO_PAGE_X_FIX));
85 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_zip || page_zip == &block->page.zip);
86 constexpr uint16_tcxx . . $ uint16_t# field= FIL_RTREE_SPLIT_SEQ_NUMcxx . . $ `storage/innobase/include/fil0fil.h:1239:9`!;
87 bytecxx . . $ byte# *b= my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<2>(&block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.[field]);
88 if (mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<8,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, b, ssn_id) &&
89 UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(page_zip))
90 memcpy_alignedcxx . . $ memcpy_aligned(cc817cb175f282d).<2>(&page_zip->datacxx . . $ page_zip_des_t#data.[field], b, 8);
91 }
92
93 #endif /* !UNIV_INNOCHECKSUM */
94
95 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
96 /*************************************************************//**
97 Returns the offset stored in the given header field.
98 @return offset from the start of the page, or 0 */
99 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
100 uint16_tcxx . . $ uint16_t#
101 page_header_get_offscxx . . $ page_header_get_offs(cbdda48327e67104).(
102 /*=================*/
103 const page_tcxx . . $ ib_page_t#* page, /*!< in: page */
104 ulintcxx . . $ ulint# field) /*!< in: PAGE_FREE, ... */
105 {
106 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((field == PAGE_FREE)
107 || (field == PAGE_LAST_INSERT)
108 || (field == PAGE_HEAP_TOP));
109
110 uint16_tcxx . . $ uint16_t# offs = page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, field);
111
112 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((field != PAGE_HEAP_TOP) || offs);
113
114 return(offs);
115 }
116
117
118 /**
119 Reset PAGE_LAST_INSERT.
120 @param[in,out] block file page
121 @param[in,out] mtr mini-transaction */
122 inline void page_header_reset_last_insertcxx . . $ page_header_reset_last_insert(c4796673375b2726).(buf_block_tcxx . . $ buf_block_t# *block, mtr_tcxx . . $ mtr_t# *mtr)
123 {
124 constexpr uint16_tcxx . . $ uint16_t# field= PAGE_HEADERcxx . . $ `storage/innobase/include/page0page.h:48:9`! + PAGE_LAST_INSERTcxx . . $ `storage/innobase/include/page0page.h:57:9`!;
125 bytecxx . . $ byte# *b= my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<2>(&block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.[field]);
126 if (mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<2,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, b, 0U) &&
127 UNIV_LIKELY_NULLcxx . . $ buf_page_t#zip.(block->page.zip.data))
128 memset_alignedcxx . . $ memset_aligned(d1de1e4fb215f1c6).<2>(&block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data.[field], 0, 2);
129 }
130
131 #ifdef UNIV_DEBUG
132 /***************************************************************//**
133 Returns the heap number of a record.
134 @return heap number */
135 UNIV_INLINE
136 ulint
137 page_rec_get_heap_no(
138 /*=================*/
139 const rec_t* rec) /*!< in: the physical record */
140 {
141 if (page_rec_is_comp(rec)) {
142 return(rec_get_heap_no_new(rec));
143 } else {
144 return(rec_get_heap_no_old(rec));
145 }
146 }
147 #endif
148
149 /** Determine whether an index page record is a user record.
150 @param[in] rec record in an index page
151 @return true if a user record */
152 inline
153 bool
154 page_rec_is_user_reccxx . . $ page_rec_is_user_rec(190063cf6fb4afb1).(const rec_tcxx . . $ rec_t#* rec)
155 {
156 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_check(rec));
157 return(page_rec_is_user_rec_lowcxx . . $ page_rec_is_user_rec_low(31596a199e1d8a50).(page_offsetcxx . . $ page_offset(70c5808fd903031e).(rec)));
158 }
159
160 /** Determine whether an index page record is the supremum record.
161 @param[in] rec record in an index page
162 @return true if the supremum record */
163 inline
164 bool
165 page_rec_is_supremumcxx . . $ page_rec_is_supremum(190063cf6fb4afb1).(const rec_tcxx . . $ rec_t#* rec)
166 {
167 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_check(rec));
168 return(page_rec_is_supremum_lowcxx . . $ page_rec_is_supremum_low(31596a199e1d8a50).(page_offsetcxx . . $ page_offset(70c5808fd903031e).(rec)));
169 }
170
171 /** Determine whether an index page record is the infimum record.
172 @param[in] rec record in an index page
173 @return true if the infimum record */
174 inline
175 bool
176 page_rec_is_infimumcxx . . $ page_rec_is_infimum(190063cf6fb4afb1).(const rec_tcxx . . $ rec_t#* rec)
177 {
178 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_check(rec));
179 return(page_rec_is_infimum_lowcxx . . $ page_rec_is_infimum_low(31596a199e1d8a50).(page_offsetcxx . . $ page_offset(70c5808fd903031e).(rec)));
180 }
181
182 /************************************************************//**
183 true if the record is the first user record on a page.
184 @return true if the first user record */
185 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
186 bool
187 page_rec_is_firstcxx . . $ page_rec_is_first(27c8776bc8033bc9).(
188 /*==============*/
189 const rec_tcxx . . $ rec_t#* rec, /*!< in: record */
190 const page_tcxx . . $ ib_page_t#* page) /*!< in: page */
191 {
192 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_get_n_recs(page) > 0);
193
194 return(page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).(page_get_infimum_reccxx . . $ page_get_infimum_offset(ca1608e2c87725e2).(page)) == rec);
195 }
196
197 /************************************************************//**
198 true if the record is the last user record on a page.
199 @return true if the last user record */
200 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
201 bool
202 page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(
203 /*=============*/
204 const rec_tcxx . . $ rec_t#* rec, /*!< in: record */
205 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page) /*!< in: page */
206 {
207 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_get_n_recs(page) > 0);
208
209 return(page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).(rec) == page_get_supremum_reccxx . . $ `storage/innobase/include/page0page.h:532:9`!(page));
210 }
211
212 /************************************************************//**
213 Returns the middle record of the records on the page. If there is an
214 even number of records in the list, returns the first record of the
215 upper half-list.
216 @return middle record */
217 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
218 rec_tcxx . . $ rec_t#*
219 page_get_middle_reccxx . . $ page_get_middle_rec(adcd832f8377c3d8).(
220 /*================*/
221 page_tcxx . . $ ib_page_t#* page) /*!< in: page */
222 {
223 ulintcxx . . $ ulint# middle = (ulintcxx . . $ ulint#(page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page))
224 + PAGE_HEAP_NO_USER_LOWcxx . . $ `storage/innobase/include/page0page.h:155:9`!) / 2;
225
226 return(page_rec_get_nthcxx . . $ page_rec_get_nth(7ccb9c26b1180419).(page, middle));
227 }
228
229 #endif /* !UNIV_INNOCHECKSUM */
230
231 /*************************************************************//**
232 Gets the page number.
233 @return page number */
234 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
235 uint32_tcxx . . $ uint32_t#
236 page_get_page_nocxx . . $ page_get_page_no(ca1608e2c87725e2).(
237 /*=============*/
238 const page_tcxx . . $ ib_page_t#* page) /*!< in: page */
239 {
240 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
241 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page == page_align(page));
242 #endif /* !UNIV_INNOCHECKSUM */
243 return mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<4>(page + FIL_PAGE_OFFSETcxx . . $ `storage/innobase/include/fil0fil.h:1195:9`!));
244 }
245
246 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
247 /*************************************************************//**
248 Gets the tablespace identifier.
249 @return space id */
250 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
251 uint32_tcxx . . $ uint32_t#
252 page_get_space_idcxx . . $ page_get_space_id(ca1608e2c87725e2).(
253 /*==============*/
254 const page_tcxx . . $ ib_page_t#* page) /*!< in: page */
255 {
256 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page == page_align(page));
257 return mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<2>
258 (page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_IDcxx . . $ `storage/innobase/include/fil0fil.h:1245:9`!));
259 }
260
261 #endif /* !UNIV_INNOCHECKSUM */
262
263 /*************************************************************//**
264 Gets the number of user records on page (infimum and supremum records
265 are not user records).
266 @return number of user records */
267 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
268 uint16_tcxx . . $ uint16_t#
269 page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(
270 /*============*/
271 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page) /*!< in: index page */
272 {
273 return(page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_N_RECScxx . . $ `storage/innobase/include/page0page.h:96:9`!));
274 }
275
276 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
277 /*************************************************************//**
278 Gets the number of dir slots in directory.
279 @return number of slots */
280 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
281 uint16_tcxx . . $ uint16_t#
282 page_dir_get_n_slotscxx . . $ page_dir_get_n_slots(469dcb4e54b221a8).(
283 /*=================*/
284 const page_tcxx . . $ ib_page_t#* page) /*!< in: index page */
285 {
286 return(page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_N_DIR_SLOTScxx . . $ `storage/innobase/include/page0page.h:51:9`!));
287 }
288
289 /*************************************************************//**
290 Gets the number of records in the heap.
291 @return number of user records */
292 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
293 uint16_tcxx . . $ uint16_t#
294 page_dir_get_n_heapcxx . . $ page_dir_get_n_heap(469dcb4e54b221a8).(
295 /*================*/
296 const page_tcxx . . $ ib_page_t#* page) /*!< in: index page */
297 {
298 return(page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_N_HEAPcxx . . $ `storage/innobase/include/page0page.h:53:9`!) & 0x7fff);
299 }
300
301 /**************************************************************//**
302 Used to check the consistency of a record on a page.
303 @return TRUE if succeed */
304 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
305 iboolcxx . . $ ulint#
306 page_rec_checkcxx . . $ page_rec_check(b191ace3c5bffbd9).(
307 /*===========*/
308 const rec_tcxx . . $ rec_t#* rec) /*!< in: record */
309 {
310 const page_tcxx . . $ ib_page_t#* page = page_aligncxx . . $ page_align(caf1b19b4c17f9f6).(rec);
311
312 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(rec);
313
314 ut_acxx . . $ ulint#(page_offset(rec) <= page_header_get_field(page, PAGE_HEAP_TOPcxx . . $ `storage/innobase/include/page0page.h:52:9`!));
315 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(page_offset(rec) >= PAGE_DATAcxx . . $ `storage/innobase/include/page0page.h:129:9`!);
316
317 return(TRUEcxx . . $ `include/my_global.h:476:9`!);
318 }
319
320 /***************************************************************//**
321 Gets the number of records owned by a directory slot.
322 @return number of records */
323 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
324 ulintcxx . . $ ulint#
325 page_dir_slot_get_n_ownedcxx . . $ page_dir_slot_get_n_owned(b191ace3c5bffbd9).(
326 /*======================*/
327 const page_dir_slot_tcxx . . $ page_dir_slot_t#* slot) /*!< in: page directory slot */
328 {
329 const rec_tcxx . . $ rec_t#* rec = page_dir_slot_get_reccxx . . $ page_dir_slot_get_rec(ae0d43ef6a3e393f).(slot);
330 if (page_rec_is_compcxx . . $ page_rec_is_comp(f3688bc2ee54ea05).(slot)) {
331 return(rec_get_n_owned_newcxx . . $ rec_get_n_owned_new(b191ace3c5bffbd9).(rec));
332 } else {
333 return(rec_get_n_owned_oldcxx . . $ rec_get_n_owned_old(b191ace3c5bffbd9).(rec));
334 }
335 }
336
337 /************************************************************//**
338 Calculates the space reserved for directory slots of a given number of
339 records. The exact value is a fraction number n * PAGE_DIR_SLOT_SIZE /
340 PAGE_DIR_SLOT_MIN_N_OWNED, and it is rounded upwards to an integer. */
341 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
342 ulintcxx . . $ ulint#
343 page_dir_calc_reserved_spacecxx . . $ page_dir_calc_reserved_space(ecdaa1632f49f591).(
344 /*=========================*/
345 ulintcxx . . $ ulint# n_recs) /*!< in: number of records */
346 {
347 return((PAGE_DIR_SLOT_SIZEcxx . . $ PAGE_DIR_SLOT_SIZE. * n_recs + PAGE_DIR_SLOT_MIN_N_OWNEDcxx . . $ `storage/innobase/include/page0page.h:191:9`! - 1)
348 / PAGE_DIR_SLOT_MIN_N_OWNEDcxx . . $ `storage/innobase/include/page0page.h:191:9`!);
349 }
350
351 /************************************************************//**
352 Gets the pointer to the next record on the page.
353 @return pointer to next record */
354 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
355 const rec_tcxx . . $ rec_t#*
356 page_rec_get_next_lowcxx . . $ page_rec_get_next_low(d621370e5107e08e).(
357 /*==================*/
358 const rec_tcxx . . $ rec_t#* rec, /*!< in: pointer to record */
359 ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page layout */
360 {
361 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *page= page_aligncxx . . $ page_align(caf1b19b4c17f9f6).(rec);
362 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_check(rec));
363 ulintcxx . . $ ulint# offs= rec_get_next_offscxx . . $ rec_get_next_offs(4adc7973d4c4f159).(rec, comp);
364 if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(offs < (comp ? PAGE_NEW_SUPREMUMcxx . . $ `storage/innobase/include/page0page.h:144:9`! : PAGE_OLD_SUPREMUMcxx . . $ `storage/innobase/include/page0page.h:135:9`!)))
365 return nullptr;
366 if (UNIV_UNLIKELYcxx . . $ page_header_get_field(cbdda48327e67104).(offs > page_header_get_field(page, PAGE_HEAP_TOPcxx . . $ `storage/innobase/include/page0page.h:52:9`!)))
367 return nullptr;
368 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_is_infimum(rec) ||
369 (!page_is_leaf(page) && !page_has_prev(page)) ||
370 !(rec_get_info_bits(page + offs, comp) & REC_INFO_MIN_REC_FLAG));
371 return page + offs;
372 }
373
374 /************************************************************//**
375 Gets the pointer to the next record on the page.
376 @return pointer to next record */
377 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
378 rec_tcxx . . $ rec_t#*
379 page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(
380 /*==============*/
381 rec_tcxx . . $ rec_t#* rec) /*!< in: pointer to record */
382 {
383 return((rec_tcxx . . $ rec_t#*) page_rec_get_next_lowcxx . . $ page_rec_get_next_low(d621370e5107e08e).(rec, page_rec_is_compcxx . . $ page_rec_is_comp(f3688bc2ee54ea05).(rec)));
384 }
385
386 /************************************************************//**
387 Gets the pointer to the next record on the page.
388 @return pointer to next record */
389 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
390 const rec_tcxx . . $ rec_t#*
391 page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).(
392 /*====================*/
393 const rec_tcxx . . $ rec_t#* rec) /*!< in: pointer to record */
394 {
395 return(page_rec_get_next_lowcxx . . $ page_rec_get_next_low(d621370e5107e08e).(rec, page_rec_is_compcxx . . $ page_rec_is_comp(f3688bc2ee54ea05).(rec)));
396 }
397 #endif /* UNIV_INNOCHECKSUM */
398
399 /************************************************************//**
400 Returns the sum of the sizes of the records in the record list, excluding
401 the infimum and supremum records.
402 @return data in bytes */
403 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
404 uint16_tcxx . . $ uint16_t#
405 page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(
406 /*===============*/
407 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page) /*!< in: index page */
408 {
409 unsigned ret = page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_HEAP_TOPcxx . . $ `storage/innobase/include/page0page.h:52:9`!)
410 - (page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page)
411 ? PAGE_NEW_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:147:9`!
412 : PAGE_OLD_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:138:9`!)
413 - page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_GARBAGEcxx . . $ `storage/innobase/include/page0page.h:56:9`!);
414 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(ret < srv_page_size);
415 return static_cast<uint16_tcxx . . $ uint16_t#>(ret);
416 }
417
418 #ifndef UNIV_INNOCHECKSUMcxx . . $ `<built-in>:481:9`!
419 /*************************************************************//**
420 Calculates free space if a page is emptied.
421 @return free space */
422 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
423 ulintcxx . . $ ulint#
424 page_get_free_space_of_emptycxx . . $ page_get_free_space_of_empty(ecdaa1632f49f591).(
425 /*=========================*/
426 ulintcxx . . $ ulint# comp) /*!< in: nonzero=compact page layout */
427 {
428 if (comp) {
429 return((ulintcxx . . $ ulint#)(srv_page_sizecxx . . $ srv_page_size.
430 - PAGE_NEW_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:147:9`!
431 - PAGE_DIRcxx . . $ `storage/innobase/include/page0page.h:178:9`!
432 - 2 * PAGE_DIR_SLOT_SIZEcxx . . $ PAGE_DIR_SLOT_SIZE.));
433 }
434
435 return((ulintcxx . . $ ulint#)(srv_page_sizecxx . . $ srv_page_size.
436 - PAGE_OLD_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:138:9`!
437 - PAGE_DIRcxx . . $ `storage/innobase/include/page0page.h:178:9`!
438 - 2 * PAGE_DIR_SLOT_SIZEcxx . . $ PAGE_DIR_SLOT_SIZE.));
439 }
440
441 /************************************************************//**
442 Each user record on a page, and also the deleted user records in the heap
443 takes its size plus the fraction of the dir cell size /
444 PAGE_DIR_SLOT_MIN_N_OWNED bytes for it. If the sum of these exceeds the
445 value of page_get_free_space_of_empty, the insert is impossible, otherwise
446 it is allowed. This function returns the maximum combined size of records
447 which can be inserted on top of the record heap.
448 @return maximum combined size for inserted records */
449 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
450 ulintcxx . . $ ulint#
451 page_get_max_insert_sizecxx . . $ page_get_max_insert_size(4adc7973d4c4f159).(
452 /*=====================*/
453 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page, /*!< in: index page */
454 ulintcxx . . $ ulint# n_recs) /*!< in: number of records */
455 {
456 ulintcxx . . $ ulint# occupied;
457 ulintcxx . . $ ulint# free_space;
458
459 if (page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page)) {
460 occupied = page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_HEAP_TOPcxx . . $ `storage/innobase/include/page0page.h:52:9`!)
461 - PAGE_NEW_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:147:9`!
462 + page_dir_calc_reserved_spacecxx . . $ page_dir_calc_reserved_space(ecdaa1632f49f591).(
463 n_recs + page_dir_get_n_heapcxx . . $ page_dir_get_n_heap(469dcb4e54b221a8).(page) - 2);
464
465 free_space = page_get_free_space_of_emptycxx . . $ page_get_free_space_of_empty(ecdaa1632f49f591).(TRUEcxx . . $ `include/my_global.h:476:9`!);
466 } else {
467 occupied = page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_HEAP_TOPcxx . . $ `storage/innobase/include/page0page.h:52:9`!)
468 - PAGE_OLD_SUPREMUM_ENDcxx . . $ `storage/innobase/include/page0page.h:138:9`!
469 + page_dir_calc_reserved_spacecxx . . $ page_dir_calc_reserved_space(ecdaa1632f49f591).(
470 n_recs + page_dir_get_n_heapcxx . . $ page_dir_get_n_heap(469dcb4e54b221a8).(page) - 2);
471
472 free_space = page_get_free_space_of_emptycxx . . $ page_get_free_space_of_empty(ecdaa1632f49f591).(FALSEcxx . . $ `include/my_global.h:477:9`!);
473 }
474
475 /* Above the 'n_recs +' part reserves directory space for the new
476 inserted records; the '- 2' excludes page infimum and supremum
477 records */
478
479 if (occupied > free_space) {
480
481 return(0);
482 }
483
484 return(free_space - occupied);
485 }
486
487 /************************************************************//**
488 Returns the maximum combined size of records which can be inserted on top
489 of the record heap if a page is first reorganized.
490 @return maximum combined size for inserted records */
491 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
492 ulintcxx . . $ ulint#
493 page_get_max_insert_size_after_reorganizecxx . . $ page_get_max_insert_size_after_reorganize(4adc7973d4c4f159).(
494 /*======================================*/
495 const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page, /*!< in: index page */
496 ulintcxx . . $ ulint# n_recs) /*!< in: number of records */
497 {
498 ulintcxx . . $ ulint# occupied;
499 ulintcxx . . $ ulint# free_space;
500
501 occupied = page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page)
502 + page_dir_calc_reserved_spacecxx . . $ page_dir_calc_reserved_space(ecdaa1632f49f591).(n_recs + page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page));
503
504 free_space = page_get_free_space_of_emptycxx . . $ page_get_free_space_of_empty(ecdaa1632f49f591).(page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page));
505
506 if (occupied > free_space) {
507
508 return(0);
509 }
510
511 return(free_space - occupied);
512 }
513
514 /** Read the PAGE_DIRECTION field from a byte.
515 @param[in] ptr pointer to PAGE_DIRECTION_B
516 @return the value of the PAGE_DIRECTION field */
517 inline
518 bytecxx . . $ byte#
519 page_ptr_get_directioncxx . . $ page_ptr_get_direction(f3688bc2ee54ea05).(const bytecxx . . $ byte#* ptr)
520 {
521 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_offset(ptr) == PAGE_HEADER + PAGE_DIRECTION_B);
522 return *ptr & ((1U << 3) - 1);
523 }
524
525 /** Read the PAGE_INSTANT field.
526 @param[in] page index page
527 @return the value of the PAGE_INSTANT field */
528 inline
529 uint16_tcxx . . $ uint16_t#
530 page_get_instantcxx . . $ page_get_instant(469dcb4e54b221a8).(const page_tcxx . . $ ib_page_t#* page)
531 {
532 uint16_tcxx . . $ uint16_t# i = page_header_get_fieldcxx . . $ page_header_get_field(cbdda48327e67104).(page, PAGE_INSTANTcxx . . $ `storage/innobase/include/page0page.h:88:9`!);
533 #ifdef UNIV_DEBUG
534 switch (fil_page_get_type(page)) {
535 case FIL_PAGE_TYPE_INSTANT:
536 ut_ad(page_get_direction(page) <= PAGE_NO_DIRECTION);
537 ut_ad(i >> 3);
538 break;
539 case FIL_PAGE_INDEX:
540 ut_ad(i <= PAGE_NO_DIRECTION || !page_is_comp(page));
541 break;
542 case FIL_PAGE_RTREE:
543 ut_ad(i <= PAGE_NO_DIRECTION);
544 break;
545 default:
546 ut_ad("invalid page type" == 0);
547 break;
548 }
549 #endif /* UNIV_DEBUG */
550 return static_cast<uint16_tcxx . . $ uint16_t#>(i >> 3); /* i / 8 */
551 }
552 #endif /* !UNIV_INNOCHECKSUM */