1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2019, 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/fut0fut.h
22 File-based utilities
23 
24 Created 12/13/1995 Heikki Tuuri
25 ***********************************************************************/
26 
27 
28 #ifndef fut0fut_h
29 #define fut0fut_h
30 
31 #include "mtr0mtr.h"
32 
33 /** Gets a pointer to a file address and latches the page.
34 @param[in]	space		space id
35 @param[in]	zip_size	ROW_FORMAT=COMPRESSED page size, or 0
36 @param[in]	addr		file address
37 @param[in]	rw_latch	RW_S_LATCH, RW_X_LATCH, RW_SX_LATCH
38 @param[out]	ptr_block	file page
39 @param[in,out]	mtr		mini-transaction
40 @return pointer to a byte in (*ptr_block)->frame; the *ptr_block is
41 bufferfixed and latched */
42 UNIV_INLINE
43 byte*
44 fut_get_ptr(
45 	ulint			space,
46 	ulint			zip_size,
47 	fil_addr_t		addr,
48 	rw_lock_type_t		rw_latch,
49 	mtr_t*			mtr,
50 	buf_block_t**		ptr_block = NULL)
51 {
52 	buf_block_t*	block;
53 	byte*		ptr = NULL;
54 
55 	ut_ad(addr.boffset < srv_page_size);
56 	ut_ad((rw_latch == RW_S_LATCH)
57 	      || (rw_latch == RW_X_LATCH)
58 	      || (rw_latch == RW_SX_LATCH));
59 
60 	block = buf_page_get(page_id_t(space, addr.page), zip_size,
61 			     rw_latch, mtr);
62 
63 	ptr = buf_block_get_frame(block) + addr.boffset;
64 
65 	buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
66 
67 	if (ptr_block != NULL) {
68 		*ptr_block = block;
69 	}
70 
71 	return(ptr);
72 }
73 
74 #endif /* fut0fut_h */
75