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.h
21
File-based list utilities
23
Created 11/28/1995 Heikki Tuuri
24
***********************************************************************/
35
/* The C 'types' of base node and list node: these should be used to
36
write self-documenting code. Of course, the sizeof macro cannot be
37
applied to these types! */
39
typedef byte flst_base_node_t;
40
typedef byte flst_node_t;
42
/* The physical size of a list base node in bytes */
43
#define FLST_BASE_NODE_SIZE (4 + 2 * FIL_ADDR_SIZE)
45
/* The physical size of a list node in bytes */
46
#define FLST_NODE_SIZE (2 * FIL_ADDR_SIZE)
48
#ifndef UNIV_HOTBACKUP
49
/********************************************************************//**
50
Initializes a list base node. */
55
flst_base_node_t* base, /*!< in: pointer to base node */
56
mtr_t* mtr); /*!< in: mini-transaction handle */
57
/********************************************************************//**
58
Adds a node as the last node in a list. */
63
flst_base_node_t* base, /*!< in: pointer to base node of list */
64
flst_node_t* node, /*!< in: node to add */
65
mtr_t* mtr); /*!< in: mini-transaction handle */
66
/********************************************************************//**
67
Adds a node as the first node in a list. */
72
flst_base_node_t* base, /*!< in: pointer to base node of list */
73
flst_node_t* node, /*!< in: node to add */
74
mtr_t* mtr); /*!< in: mini-transaction handle */
75
/********************************************************************//**
76
Inserts a node after another in a list. */
81
flst_base_node_t* base, /*!< in: pointer to base node of list */
82
flst_node_t* node1, /*!< in: node to insert after */
83
flst_node_t* node2, /*!< in: node to add */
84
mtr_t* mtr); /*!< in: mini-transaction handle */
85
/********************************************************************//**
86
Inserts a node before another in a list. */
91
flst_base_node_t* base, /*!< in: pointer to base node of list */
92
flst_node_t* node2, /*!< in: node to insert */
93
flst_node_t* node3, /*!< in: node to insert before */
94
mtr_t* mtr); /*!< in: mini-transaction handle */
95
/********************************************************************//**
101
flst_base_node_t* base, /*!< in: pointer to base node of list */
102
flst_node_t* node2, /*!< in: node to remove */
103
mtr_t* mtr); /*!< in: mini-transaction handle */
104
/********************************************************************//**
105
Cuts off the tail of the list, including the node given. The number of
106
nodes which will be removed must be provided by the caller, as this function
107
does not measure the length of the tail. */
112
flst_base_node_t* base, /*!< in: pointer to base node of list */
113
flst_node_t* node2, /*!< in: first node to remove */
114
ulint n_nodes,/*!< in: number of nodes to remove,
116
mtr_t* mtr); /*!< in: mini-transaction handle */
117
/********************************************************************//**
118
Cuts off the tail of the list, not including the given node. The number of
119
nodes which will be removed must be provided by the caller, as this function
120
does not measure the length of the tail. */
125
flst_base_node_t* base, /*!< in: pointer to base node of list */
126
flst_node_t* node2, /*!< in: first node not to remove */
127
ulint n_nodes,/*!< in: number of nodes to remove */
128
mtr_t* mtr); /*!< in: mini-transaction handle */
129
/********************************************************************//**
136
const flst_base_node_t* base, /*!< in: pointer to base node */
137
mtr_t* mtr); /*!< in: mini-transaction handle */
138
/********************************************************************//**
139
Gets list first node address.
140
@return file address */
145
const flst_base_node_t* base, /*!< in: pointer to base node */
146
mtr_t* mtr); /*!< in: mini-transaction handle */
147
/********************************************************************//**
148
Gets list last node address.
149
@return file address */
154
const flst_base_node_t* base, /*!< in: pointer to base node */
155
mtr_t* mtr); /*!< in: mini-transaction handle */
156
/********************************************************************//**
157
Gets list next node address.
158
@return file address */
163
const flst_node_t* node, /*!< in: pointer to node */
164
mtr_t* mtr); /*!< in: mini-transaction handle */
165
/********************************************************************//**
166
Gets list prev node address.
167
@return file address */
172
const flst_node_t* node, /*!< in: pointer to node */
173
mtr_t* mtr); /*!< in: mini-transaction handle */
174
/********************************************************************//**
175
Writes a file address. */
180
fil_faddr_t* faddr, /*!< in: pointer to file faddress */
181
fil_addr_t addr, /*!< in: file address */
182
mtr_t* mtr); /*!< in: mini-transaction handle */
183
/********************************************************************//**
184
Reads a file address.
185
@return file address */
190
const fil_faddr_t* faddr, /*!< in: pointer to file faddress */
191
mtr_t* mtr); /*!< in: mini-transaction handle */
192
/********************************************************************//**
193
Validates a file-based list.
194
@return TRUE if ok */
199
const flst_base_node_t* base, /*!< in: pointer to base node of list */
200
mtr_t* mtr1); /*!< in: mtr */
201
/********************************************************************//**
202
Prints info of a file-based list. */
207
const flst_base_node_t* base, /*!< in: pointer to base node of list */
208
mtr_t* mtr); /*!< in: mtr */
212
#include "fut0lst.ic"
215
#endif /* !UNIV_HOTBACKUP */