| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 1995, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/fut0fut.ic |
| 29 |
File-based utilities |
| 30 |
|
| 31 |
Created 12/13/1995 Heikki Tuuri |
| 32 |
***********************************************************************/ |
| 33 |
|
| 34 |
#include "buf0buf.h" |
| 35 |
#include "sync0rw.h" |
| 36 |
|
| 37 |
/** Gets a pointer to a file address and latches the page. |
| 38 |
@param[in] space Space id |
| 39 |
@param[in] page_size Page size |
| 40 |
@param[in] addr File address |
| 41 |
@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_SX_LATCH |
| 42 |
@param[in,out] mtr Mini-transaction |
| 43 |
@param[out] ptr_block File page |
| 44 |
@return pointer to a byte in (*ptr_block)->frame; the *ptr_block is |
| 45 |
bufferfixed and latched */ |
| 46 |
static inline byte *fut_get_ptr(space_id_t space, const page_size_t &page_size, |
| 47 |
fil_addr_t addr, rw_lock_type_t rw_latch, |
| 48 |
mtr_t *mtr, buf_block_t **ptr_block) { |
| 49 |
buf_block_t *block; |
| 50 |
byte *ptr; |
| 51 |
|
| 52 |
ut_ad(addr.boffset < UNIV_PAGE_SIZE); |
| 53 |
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH) || |
| 54 |
(rw_latch == RW_SX_LATCH)); |
| 55 |
|
| 56 |
block = buf_page_get(page_id_t(space, addr.page), page_size, rw_latch, |
| 57 |
UT_LOCATION_HERE, mtr); |
| 58 |
ptr = buf_block_get_frame(block) + addr.boffset; |
| 59 |
|
| 60 |
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); |
| 61 |
if (ptr_block != nullptr) { |
| 62 |
*ptr_block = block; |
| 63 |
} |
| 64 |
|
| 65 |
return (ptr); |
| 66 |
} |