MySQL 8.0.31
Source Code Documentation
fut0lst.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2022, Oracle and/or its affiliates.
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/fut0lst.h
28 File-based list utilities
29
30 Created 11/28/1995 Heikki Tuuri
31 ***********************************************************************/
32
33#ifndef fut0lst_h
34#define fut0lst_h
35
36#include "univ.i"
37
38#include "fil0fil.h"
39#include "mtr0mtr.h"
40
41/* The C 'types' of base node and list node: these should be used to
42write self-documenting code. Of course, the sizeof macro cannot be
43applied to these types! */
44
45typedef byte flst_base_node_t;
46typedef byte flst_node_t;
47
48/* The physical size of a list base node in bytes */
50
51/* The physical size of a list node in bytes */
53
54/** Initializes a list base node.
55@param[in] base Pointer to base node
56@param[in] mtr Mini-transaction handle */
57static inline void flst_init(flst_base_node_t *base, mtr_t *mtr);
58
59/** Adds a node as the last node in a list.
60@param[in] base Pointer to base node of list
61@param[in] node Node to add
62@param[in] mtr Mini-transaction handle */
63void flst_add_last(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr);
64
65/** Adds a node as the first node in a list.
66@param[in] base Pointer to base node of list
67@param[in] node Node to add
68@param[in] mtr Mini-transaction handle */
69void flst_add_first(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr);
70
71/** Removes a node.
72@param[in] base Pointer to base node of list
73@param[in] node2 Node to remove
74@param[in] mtr Mini-transaction handle */
75void flst_remove(flst_base_node_t *base, flst_node_t *node2, mtr_t *mtr);
76
77/** Get the length of a list.
78@param[in] base base node
79@return length */
80static inline ulint flst_get_len(const flst_base_node_t *base);
81
82/** Gets list first node address.
83@param[in] base Pointer to base node
84@param[in] mtr Mini-transaction handle
85@return file address */
86static inline fil_addr_t flst_get_first(const flst_base_node_t *base,
87 mtr_t *mtr);
88
89/** Gets list last node address.
90@param[in] base Pointer to base node
91@param[in] mtr Mini-transaction handle
92@return file address */
93static inline fil_addr_t flst_get_last(const flst_base_node_t *base,
94 mtr_t *mtr);
95
96/** Gets list next node address.
97@param[in] node Pointer to node
98@param[in] mtr Mini-transaction handle
99@return file address */
100static inline fil_addr_t flst_get_next_addr(const flst_node_t *node,
101 mtr_t *mtr);
102
103/** Gets list prev node address.
104@param[in] node Pointer to node
105@param[in] mtr Mini-transaction handle
106@return file address */
107static inline fil_addr_t flst_get_prev_addr(const flst_node_t *node,
108 mtr_t *mtr);
109
110/** Writes a file address.
111@param[in] faddr Pointer to file faddress
112@param[in] addr File address
113@param[in] mtr Mini-transaction handle */
114static inline void flst_write_addr(fil_faddr_t *faddr, fil_addr_t addr,
115 mtr_t *mtr);
116
117/** Reads a file address.
118@param[in] faddr Pointer to file faddress
119@param[in] mtr Mini-transaction handle
120@return file address */
121static inline fil_addr_t flst_read_addr(const fil_faddr_t *faddr, mtr_t *mtr);
122
123/** Validates a file-based list.
124 @param[in] base pointer to base node of list
125 @param[in] mtr1 mtr */
126void flst_validate(const flst_base_node_t *base, mtr_t *mtr1);
127
128/** Inserts a node after another in a list.
129@param[in] base Pointer to base node of list
130@param[in] node1 Node to insert after
131@param[in] node2 Node to add
132@param[in] mtr Mini-transaction handle. */
134 flst_node_t *node2, mtr_t *mtr);
135
136/** Inserts a node before another in a list.
137@param[in] base Pointer to base node of list
138@param[in] node2 Node to insert
139@param[in] node3 Node to insert before
140@param[in] mtr Mini-transaction handle. */
142 flst_node_t *node3, mtr_t *mtr);
143
144#include "fut0lst.ic"
145
146/** In-memory representation of flst_base_node_t */
151
153
155 : len(flst_get_len(base)),
156 first(flst_get_first(base, mtr)),
157 last(flst_get_last(base, mtr)) {}
158
159 void set(const flst_base_node_t *base, mtr_t *mtr) {
160 len = flst_get_len(base);
161 first = flst_get_first(base, mtr);
162 last = flst_get_last(base, mtr);
163 }
164
165 void reset() {
166 len = 0;
169 }
170
171 std::ostream &print(std::ostream &out) const {
172 out << "[flst_base_node_t: len=" << len << ", first=" << first
173 << ", last=" << last << "]";
174 return (out);
175 }
176};
177
178inline std::ostream &operator<<(std::ostream &out, const flst_bnode_t &obj) {
179 return (obj.print(out));
180}
181
182#endif /* fut0lst_h */
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:331
The low-level file system.
byte fil_faddr_t
'type' definition in C: an address stored in a file page is a string of bytes
Definition: fil0fil.h:1136
constexpr size_t FIL_ADDR_SIZE
Address size is 6 bytes.
Definition: fil0types.h:127
static fil_addr_t flst_get_next_addr(const flst_node_t *node, mtr_t *mtr)
Gets list next node address.
void flst_add_last(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr)
Adds a node as the last node in a list.
Definition: fut0lst.cc:89
constexpr ulint FLST_BASE_NODE_SIZE
Definition: fut0lst.h:49
void flst_remove(flst_base_node_t *base, flst_node_t *node2, mtr_t *mtr)
Removes a node.
Definition: fut0lst.cc:286
static void flst_write_addr(fil_faddr_t *faddr, fil_addr_t addr, mtr_t *mtr)
Writes a file address.
byte flst_base_node_t
Definition: fut0lst.h:45
static fil_addr_t flst_read_addr(const fil_faddr_t *faddr, mtr_t *mtr)
Reads a file address.
static ulint flst_get_len(const flst_base_node_t *base)
Get the length of a list.
constexpr ulint FLST_NODE_SIZE
Definition: fut0lst.h:52
void flst_add_first(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr)
Adds a node as the first node in a list.
Definition: fut0lst.cc:132
static fil_addr_t flst_get_last(const flst_base_node_t *base, mtr_t *mtr)
Gets list last node address.
static void flst_init(flst_base_node_t *base, mtr_t *mtr)
Initializes a list base node.
static fil_addr_t flst_get_prev_addr(const flst_node_t *node, mtr_t *mtr)
Gets list prev node address.
void flst_insert_after(flst_base_node_t *base, flst_node_t *node1, flst_node_t *node2, mtr_t *mtr)
Inserts a node after another in a list.
Definition: fut0lst.cc:171
std::ostream & operator<<(std::ostream &out, const flst_bnode_t &obj)
Definition: fut0lst.h:178
void flst_validate(const flst_base_node_t *base, mtr_t *mtr1)
Validates a file-based list.
Definition: fut0lst.cc:352
static fil_addr_t flst_get_first(const flst_base_node_t *base, mtr_t *mtr)
Gets list first node address.
void flst_insert_before(flst_base_node_t *base, flst_node_t *node2, flst_node_t *node3, mtr_t *mtr)
Inserts a node before another in a list.
Definition: fut0lst.cc:227
byte flst_node_t
Definition: fut0lst.h:46
File-based list utilities.
Mini-transaction buffer.
File space address.
Definition: fil0fil.h:1139
In-memory representation of flst_base_node_t.
Definition: fut0lst.h:147
ulint len
Definition: fut0lst.h:148
std::ostream & print(std::ostream &out) const
Definition: fut0lst.h:171
flst_bnode_t()
Definition: fut0lst.h:152
fil_addr_t last
Definition: fut0lst.h:150
flst_bnode_t(const flst_base_node_t *base, mtr_t *mtr)
Definition: fut0lst.h:154
void set(const flst_base_node_t *base, mtr_t *mtr)
Definition: fut0lst.h:159
fil_addr_t first
Definition: fut0lst.h:149
void reset()
Definition: fut0lst.h:165
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:181
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407