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