MySQL 8.4.1
Source Code Documentation
fut0lst.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2024, 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 designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/fut0lst.h
29 File-based list utilities
30
31 Created 11/28/1995 Heikki Tuuri
32 ***********************************************************************/
33
34#ifndef fut0lst_h
35#define fut0lst_h
36
37#include "univ.i"
38
39#include "fil0fil.h"
40#include "mtr0mtr.h"
41
42/* The C 'types' of base node and list node: these should be used to
43write self-documenting code. Of course, the sizeof macro cannot be
44applied to these types! */
45
46typedef byte flst_base_node_t;
47typedef byte flst_node_t;
48
49/* The physical size of a list base node in bytes */
51
52/* The physical size of a list node in bytes */
54
55/** Initializes a list base node.
56@param[in] base Pointer to base node
57@param[in] mtr Mini-transaction handle */
58static inline void flst_init(flst_base_node_t *base, mtr_t *mtr);
59
60/** Adds a node as the last node in a list.
61@param[in] base Pointer to base node of list
62@param[in] node Node to add
63@param[in] mtr Mini-transaction handle */
64void flst_add_last(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr);
65
66/** Adds a node as the first node in a list.
67@param[in] base Pointer to base node of list
68@param[in] node Node to add
69@param[in] mtr Mini-transaction handle */
70void flst_add_first(flst_base_node_t *base, flst_node_t *node, mtr_t *mtr);
71
72/** Removes a node.
73@param[in] base Pointer to base node of list
74@param[in] node2 Node to remove
75@param[in] mtr Mini-transaction handle */
76void flst_remove(flst_base_node_t *base, flst_node_t *node2, mtr_t *mtr);
77
78/** Get the length of a list.
79@param[in] base base node
80@return length */
81static inline ulint flst_get_len(const flst_base_node_t *base);
82
83/** Gets list first node address.
84@param[in] base Pointer to base node
85@param[in] mtr Mini-transaction handle
86@return file address */
87static inline fil_addr_t flst_get_first(const flst_base_node_t *base,
88 mtr_t *mtr);
89
90/** Gets list last node address.
91@param[in] base Pointer to base node
92@param[in] mtr Mini-transaction handle
93@return file address */
94static inline fil_addr_t flst_get_last(const flst_base_node_t *base,
95 mtr_t *mtr);
96
97/** Gets list next node address.
98@param[in] node Pointer to node
99@param[in] mtr Mini-transaction handle
100@return file address */
101static inline fil_addr_t flst_get_next_addr(const flst_node_t *node,
102 mtr_t *mtr);
103
104/** Gets list prev node address.
105@param[in] node Pointer to node
106@param[in] mtr Mini-transaction handle
107@return file address */
108static inline fil_addr_t flst_get_prev_addr(const flst_node_t *node,
109 mtr_t *mtr);
110
111/** Writes a file address.
112@param[in] faddr Pointer to file faddress
113@param[in] addr File address
114@param[in] mtr Mini-transaction handle */
115static inline void flst_write_addr(fil_faddr_t *faddr, fil_addr_t addr,
116 mtr_t *mtr);
117
118/** Reads a file address.
119@param[in] faddr Pointer to file faddress
120@param[in] mtr Mini-transaction handle
121@return file address */
122static inline fil_addr_t flst_read_addr(const fil_faddr_t *faddr, mtr_t *mtr);
123
124/** Validates a file-based list.
125 @param[in] base pointer to base node of list
126 @param[in] mtr1 mtr */
127void flst_validate(const flst_base_node_t *base, mtr_t *mtr1);
128
129/** Inserts a node after another in a list.
130@param[in] base Pointer to base node of list
131@param[in] node1 Node to insert after
132@param[in] node2 Node to add
133@param[in] mtr Mini-transaction handle. */
135 flst_node_t *node2, mtr_t *mtr);
136
137/** Inserts a node before another in a list.
138@param[in] base Pointer to base node of list
139@param[in] node2 Node to insert
140@param[in] node3 Node to insert before
141@param[in] mtr Mini-transaction handle. */
143 flst_node_t *node3, mtr_t *mtr);
144
145#include "fut0lst.ic"
146
147/** In-memory representation of flst_base_node_t */
152
154
156 : len(flst_get_len(base)),
157 first(flst_get_first(base, mtr)),
158 last(flst_get_last(base, mtr)) {}
159
160 void set(const flst_base_node_t *base, mtr_t *mtr) {
161 len = flst_get_len(base);
162 first = flst_get_first(base, mtr);
163 last = flst_get_last(base, mtr);
164 }
165
166 void reset() {
167 len = 0;
170 }
171
172 std::ostream &print(std::ostream &out) const {
173 out << "[flst_base_node_t: len=" << len << ", first=" << first
174 << ", last=" << last << "]";
175 return (out);
176 }
177};
178
179inline std::ostream &operator<<(std::ostream &out, const flst_bnode_t &obj) {
180 return (obj.print(out));
181}
182
183#endif /* fut0lst_h */
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:326
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:1173
constexpr size_t FIL_ADDR_SIZE
Address size is 6 bytes.
Definition: fil0types.h:128
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:90
constexpr ulint FLST_BASE_NODE_SIZE
Definition: fut0lst.h:50
void flst_remove(flst_base_node_t *base, flst_node_t *node2, mtr_t *mtr)
Removes a node.
Definition: fut0lst.cc:287
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:46
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:53
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:133
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:172
std::ostream & operator<<(std::ostream &out, const flst_bnode_t &obj)
Definition: fut0lst.h:179
void flst_validate(const flst_base_node_t *base, mtr_t *mtr1)
Validates a file-based list.
Definition: fut0lst.cc:353
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:228
byte flst_node_t
Definition: fut0lst.h:47
File-based list utilities.
Mini-transaction buffer.
File space address.
Definition: fil0fil.h:1176
In-memory representation of flst_base_node_t.
Definition: fut0lst.h:148
ulint len
Definition: fut0lst.h:149
std::ostream & print(std::ostream &out) const
Definition: fut0lst.h:172
flst_bnode_t()
Definition: fut0lst.h:153
fil_addr_t last
Definition: fut0lst.h:151
flst_bnode_t(const flst_base_node_t *base, mtr_t *mtr)
Definition: fut0lst.h:155
void set(const flst_base_node_t *base, mtr_t *mtr)
Definition: fut0lst.h:160
fil_addr_t first
Definition: fut0lst.h:150
void reset()
Definition: fut0lst.h:166
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406