1
/*****************************************************************************
3
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/******************************************************************//**
20
@file include/fut0lst.ic
21
File-based list utilities
23
Created 11/28/1995 Heikki Tuuri
24
***********************************************************************/
30
/* We define the field offsets of a node for the list */
31
#define FLST_PREV 0 /* 6-byte address of the previous list element;
32
the page part of address is FIL_NULL, if no
34
#define FLST_NEXT FIL_ADDR_SIZE /* 6-byte address of the next
35
list element; the page part of address
36
is FIL_NULL, if no next element */
38
/* We define the field offsets of a base node for the list */
39
#define FLST_LEN 0 /* 32-bit list length field */
40
#define FLST_FIRST 4 /* 6-byte address of the first element
41
of the list; undefined if empty list */
42
#define FLST_LAST (4 + FIL_ADDR_SIZE) /* 6-byte address of the
43
last element of the list; undefined
46
/********************************************************************//**
47
Writes a file address. */
52
fil_faddr_t* faddr, /*!< in: pointer to file faddress */
53
fil_addr_t addr, /*!< in: file address */
54
mtr_t* mtr) /*!< in: mini-transaction handle */
57
ut_ad(mtr_memo_contains_page(mtr, faddr, MTR_MEMO_PAGE_X_FIX));
58
ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
59
ut_a(ut_align_offset(faddr, UNIV_PAGE_SIZE) >= FIL_PAGE_DATA);
61
mlog_write_ulint(faddr + FIL_ADDR_PAGE, addr.page, MLOG_4BYTES, mtr);
62
mlog_write_ulint(faddr + FIL_ADDR_BYTE, addr.boffset,
66
/********************************************************************//**
68
@return file address */
73
const fil_faddr_t* faddr, /*!< in: pointer to file faddress */
74
mtr_t* mtr) /*!< in: mini-transaction handle */
80
addr.page = mtr_read_ulint(faddr + FIL_ADDR_PAGE, MLOG_4BYTES, mtr);
81
addr.boffset = mtr_read_ulint(faddr + FIL_ADDR_BYTE, MLOG_2BYTES,
83
ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA);
84
ut_a(ut_align_offset(faddr, UNIV_PAGE_SIZE) >= FIL_PAGE_DATA);
88
/********************************************************************//**
89
Initializes a list base node. */
94
flst_base_node_t* base, /*!< in: pointer to base node */
95
mtr_t* mtr) /*!< in: mini-transaction handle */
97
ut_ad(mtr_memo_contains_page(mtr, base, MTR_MEMO_PAGE_X_FIX));
99
mlog_write_ulint(base + FLST_LEN, 0, MLOG_4BYTES, mtr);
100
flst_write_addr(base + FLST_FIRST, fil_addr_null, mtr);
101
flst_write_addr(base + FLST_LAST, fil_addr_null, mtr);
104
/********************************************************************//**
111
const flst_base_node_t* base, /*!< in: pointer to base node */
112
mtr_t* mtr) /*!< in: mini-transaction handle */
114
return(mtr_read_ulint(base + FLST_LEN, MLOG_4BYTES, mtr));
117
/********************************************************************//**
118
Gets list first node address.
119
@return file address */
124
const flst_base_node_t* base, /*!< in: pointer to base node */
125
mtr_t* mtr) /*!< in: mini-transaction handle */
127
return(flst_read_addr(base + FLST_FIRST, mtr));
130
/********************************************************************//**
131
Gets list last node address.
132
@return file address */
137
const flst_base_node_t* base, /*!< in: pointer to base node */
138
mtr_t* mtr) /*!< in: mini-transaction handle */
140
return(flst_read_addr(base + FLST_LAST, mtr));
143
/********************************************************************//**
144
Gets list next node address.
145
@return file address */
150
const flst_node_t* node, /*!< in: pointer to node */
151
mtr_t* mtr) /*!< in: mini-transaction handle */
153
return(flst_read_addr(node + FLST_NEXT, mtr));
156
/********************************************************************//**
157
Gets list prev node address.
158
@return file address */
163
const flst_node_t* node, /*!< in: pointer to node */
164
mtr_t* mtr) /*!< in: mini-transaction handle */
166
return(flst_read_addr(node + FLST_PREV, mtr));