MySQL 9.0.0
Source Code Documentation
lob0bulk.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2016, 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/** @file include/lob0bulk.h
28
29For bulk loading large objects.
30
31*************************************************************************/
32
33#ifndef lob0bulk_h
34#define lob0bulk_h
35
36#include "lob0first.h"
37#include "lob0impl.h"
38#include "lob0pages.h"
39
40namespace Btree_multi {
41class Page_load;
42} /* namespace Btree_multi */
43
44namespace lob {
45
46namespace bulk {
47
48/** This is the bulk version in the namespace lob::bulk. */
51
53
54 void init() {
58 set_trx_id(0);
61 set_data_len(0);
62 }
63
65 ut_ad(num > 0);
66 byte *ptr = get_pageno_ptr();
67 return mach_write_ulint(ptr, num, MLOG_4BYTES);
68 }
69
70 void set_trx_undo_no(undo_no_t undo_no) {
71 byte *ptr = get_trx_undo_no_ptr();
72 mach_write_ulint(ptr, undo_no, MLOG_4BYTES);
73 }
74
77 }
78
81 }
82
83 /** The versions base node is set to NULL. */
85 byte *base_node = get_versions_ptr();
86 ::bulk::flst_init(base_node);
87 }
88
90 byte *ptr = get_trxid_ptr();
91 mach_write_to_6(ptr, id);
92 }
93
95 byte *ptr = get_trxid_modifier_ptr();
96 mach_write_to_6(ptr, id);
97 }
98
100 byte *ptr = get_trx_undo_no_modifier_ptr();
101 mach_write_ulint(ptr, undo_no, MLOG_4BYTES);
102 }
103
105 ulint new_len = get_data_len() + len;
106 set_data_len(new_len);
107 }
108
109 void set_data_len(ulint len) {
110 byte *ptr = get_datalen_ptr();
111 return mach_write_ulint(ptr, len, MLOG_2BYTES);
112 }
113
115 byte *ptr = get_datalen_ptr();
116 return mach_read_from_2(ptr);
117 }
118};
119
120/** An adapter class for handling blobs in bulk load. */
123
124 /** Initialize the first page. */
125 void init(Btree_multi::Page_load *page_load);
126
127 void set_next_page(page_no_t page_no);
128
132 }
133
135 constexpr size_t offset = lob::first_page_t::OFFSET_VERSION;
136 mach_write_ulint(frame() + offset, 0, MLOG_1BYTE);
137 }
138
140 constexpr size_t offset = lob::first_page_t::OFFSET_TRX_ID;
141 byte *ptr = frame() + offset;
142 mach_write_to_6(ptr, id);
143 }
144
145 /** Set the length of data stored in bytes.
146 @param[in] len amount of data stored in bytes. */
147 void set_data_len(ulint len) {
148 constexpr size_t offset = lob::first_page_t::OFFSET_DATA_LEN;
149 mach_write_ulint(frame() + offset, len, MLOG_4BYTES);
150 }
151
152 /** Increment the length of data stored in bytes.
153 @param[in] len amount of data stored in bytes. */
155 ulint new_len = get_data_len() + len;
157 }
158
159 /** Allocate an index entry.
160 @return nullptr if the free list is empty.
161 @return pointer to an index entry. */
163
164 /** Set the last transaction identifier.
165 @param[in] id the trx identifier. */
167 byte *ptr = frame() + OFFSET_LAST_TRX_ID;
168 mach_write_to_6(ptr, id);
169 }
170
171 /** Initialize the LOB version to 1. */
174 }
175
176 /** Get the current transaction identifier.
177 @return the current transaction identifier.*/
178 trx_id_t get_trx_id() const;
179
180 /** Get the page number of this first page.
181 @return the page number of this first page. */
182 page_no_t get_page_no() const;
183
185
186 void append_to_index(flst_node_t *node);
187
189
190 /** Get a reference to the cache of blocks.
191 @return a reference to the cache of blocks.*/
192 std::vector<buf_block_t *> &get_blocks_cache() { return m_blocks; }
193
194 private:
195 /** Initialize the free list (base node at OFFSET_INDEX_FREE_NODES) and the
196 index list (base node at OFFSET_INDEX_LIST). */
197 void init_lists();
198
200
201 /** Current index entry. */
203
204 /** blocks containing the LOB index . */
205 std::vector<buf_block_t *> m_blocks;
206};
207
209 void set_page_type();
210 void set_version_0();
211 void set_next_page(page_no_t page_no);
212 void init(Btree_multi::Page_load *node_page, first_page_t &first_page);
213
215};
216
218 void set_page_type();
219 void set_version_0();
220 void set_next_page_null();
221 void init(Btree_multi::Page_load *data_page);
222
223 /** Set the length of data stored in bytes.
224 @param[in] len amount of data stored in bytes. */
225 void set_data_len(ulint len) {
226 constexpr size_t offset = lob::data_page_t::OFFSET_DATA_LEN;
227 mach_write_ulint(frame() + offset, len, MLOG_4BYTES);
228 }
229
230 /** Increment the length of data stored in bytes.
231 @param[in] len amount of data stored in bytes. */
233 constexpr size_t offset = lob::data_page_t::OFFSET_DATA_LEN;
234 ulint new_len = get_data_len() + len;
235 mach_write_ulint(frame() + offset, new_len, MLOG_4BYTES);
236 }
237
239};
240
241} /* namespace bulk */
242} /* namespace lob */
243#endif /* lob0bulk_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:45
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
The proper function call sequence of Page_load is as below: – Page_load::init – Page_load::insert – P...
Definition: btr0mtib.h:1357
The proper function call sequence of Page_load is as below: – Page_load::init – Page_load::insert – P...
Definition: btr0load.cc:54
fil_addr_t fil_addr_null
The null file address.
Definition: fil0fil.cc:326
constexpr page_type_t FIL_PAGE_TYPE_LOB_FIRST
The first page of an uncompressed LOB.
Definition: fil0fil.h:1305
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:1156
constexpr uint32_t FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:76
static void flst_write_addr(fil_faddr_t *faddr, fil_addr_t addr, mtr_t *mtr)
Writes a file address.
static void flst_init(flst_base_node_t *base, mtr_t *mtr)
Initializes a list base node.
byte flst_node_t
Definition: fut0lst.h:47
static uint16_t mach_read_from_2(const byte *b)
The following function is used to fetch data from 2 consecutive bytes.
static void mach_write_ulint(byte *ptr, ulint val, mlog_id_t type)
Writes 1, 2 or 4 bytes to a file page.
Definition: mach0data.h:292
static void mach_write_to_6(byte *b, uint64_t id)
The following function is used to store data in 6 consecutive bytes.
@ MLOG_4BYTES
4 bytes ...
Definition: mtr0types.h:76
@ MLOG_1BYTE
one byte is written
Definition: mtr0types.h:70
@ MLOG_2BYTES
2 bytes ...
Definition: mtr0types.h:73
Definition: btr0mtib.cc:56
Used for bulk load of data.
Definition: fut0lst.cc:411
Provides the large objects (LOB) module.
Definition: lob0bulk.h:44
byte * frame() const
Definition: lob0util.h:99
Definition: lob0bulk.h:217
void set_version_0()
Definition: lob0bulk.cc:168
Btree_multi::Page_load * m_page_load
Definition: lob0bulk.h:238
void init(Btree_multi::Page_load *data_page)
Definition: lob0bulk.cc:176
void set_data_len(ulint len)
Set the length of data stored in bytes.
Definition: lob0bulk.h:225
void set_next_page_null()
Definition: lob0bulk.cc:172
void set_page_type()
Definition: lob0bulk.cc:163
void incr_data_len(ulint len)
Increment the length of data stored in bytes.
Definition: lob0bulk.h:232
An adapter class for handling blobs in bulk load.
Definition: lob0bulk.h:121
first_page_t()
Definition: lob0bulk.h:122
index_entry_t * get_index_entry()
Definition: lob0bulk.h:188
std::vector< buf_block_t * > & get_blocks_cache()
Get a reference to the cache of blocks.
Definition: lob0bulk.h:192
void set_last_trx_id(trx_id_t id)
Set the last transaction identifier.
Definition: lob0bulk.h:166
flst_node_t * alloc_index_entry()
Allocate an index entry.
Definition: lob0bulk.cc:98
void incr_data_len(ulint len)
Increment the length of data stored in bytes.
Definition: lob0bulk.h:154
void set_page_type()
Definition: lob0bulk.h:129
void set_trx_id(trx_id_t id)
Definition: lob0bulk.h:139
void set_data_len(ulint len)
Set the length of data stored in bytes.
Definition: lob0bulk.h:147
void init_lists()
Initialize the free list (base node at OFFSET_INDEX_FREE_NODES) and the index list (base node at OFFS...
Definition: lob0bulk.cc:42
void set_version_0()
Definition: lob0bulk.h:134
Btree_multi::Page_load * m_page_load
Definition: lob0bulk.h:199
void set_next_page(page_no_t page_no)
Definition: lob0bulk.cc:118
void init(Btree_multi::Page_load *page_load)
Initialize the first page.
Definition: lob0bulk.cc:60
std::vector< buf_block_t * > m_blocks
blocks containing the LOB index .
Definition: lob0bulk.h:205
trx_id_t get_trx_id() const
Get the current transaction identifier.
Definition: lob0bulk.cc:112
void init_lob_version()
Initialize the LOB version to 1.
Definition: lob0bulk.h:172
void reset_index_entry(flst_node_t *node)
Definition: lob0bulk.h:184
void append_to_index(flst_node_t *node)
Definition: lob0bulk.cc:37
index_entry_t m_index_entry
Current index entry.
Definition: lob0bulk.h:202
page_no_t get_page_no() const
Get the page number of this first page.
Definition: lob0bulk.cc:114
This is the bulk version in the namespace lob::bulk.
Definition: lob0bulk.h:49
void set_trx_id(trx_id_t id)
Definition: lob0bulk.h:89
void incr_data_len(ulint len)
Definition: lob0bulk.h:104
void init()
Definition: lob0bulk.h:54
ulint get_data_len() const
Definition: lob0bulk.h:114
void set_data_len(ulint len)
Definition: lob0bulk.h:109
void set_trx_undo_no(undo_no_t undo_no)
Definition: lob0bulk.h:70
void set_trx_undo_no_modifier(undo_no_t undo_no)
Definition: lob0bulk.h:99
void set_trx_id_modifier(trx_id_t id)
Definition: lob0bulk.h:94
void set_next_null()
Definition: lob0bulk.h:79
index_entry_t(flst_node_t *node)
Definition: lob0bulk.h:52
void set_page_no(page_no_t num)
Definition: lob0bulk.h:64
void set_versions_null()
The versions base node is set to NULL.
Definition: lob0bulk.h:84
void set_prev_null()
Definition: lob0bulk.h:75
index_entry_t()
Definition: lob0bulk.h:50
Definition: lob0bulk.h:208
void set_next_page(page_no_t page_no)
Definition: lob0bulk.cc:131
void set_page_type()
Definition: lob0bulk.cc:122
void init(Btree_multi::Page_load *node_page, first_page_t &first_page)
Definition: lob0bulk.cc:135
Btree_multi::Page_load * m_page_load
Definition: lob0bulk.h:214
void set_version_0()
Definition: lob0bulk.cc:127
The LOB data page carrying the user data.
Definition: lob0pages.h:36
static const ulint OFFSET_DATA_LEN
Definition: lob0pages.h:38
ulint get_data_len() const
Definition: lob0pages.h:122
The first page of an uncompressed LOB.
Definition: lob0first.h:43
static const ulint OFFSET_LAST_TRX_ID
The latest transaction that modified this LOB.
Definition: lob0first.h:55
ulint get_data_len() const
Definition: lob0first.h:404
static const uint32_t OFFSET_LOB_VERSION
LOB version.
Definition: lob0first.h:52
static const ulint OFFSET_TRX_ID
The trx that created the data stored in this page.
Definition: lob0first.h:64
static const ulint OFFSET_DATA_LEN
Length of data stored in this page.
Definition: lob0first.h:61
static const ulint OFFSET_VERSION
Version information.
Definition: lob0first.h:45
An index entry pointing to an LOB page.
Definition: lob0index.h:81
static const ulint OFFSET_PREV
Index entry offsets within node.
Definition: lob0index.h:83
void reset(fil_addr_t &addr)
Definition: lob0index.h:124
static const ulint OFFSET_NEXT
Definition: lob0index.h:84
byte * get_trx_undo_no_ptr() const
Get pointer to location where undo number of creator trx is written.
Definition: lob0index.h:436
byte * get_trx_undo_no_modifier_ptr() const
Get pointer to location where undo number of modifier trx is written.
Definition: lob0index.h:440
byte * get_trxid_modifier_ptr() const
Get pointer to the location where the modifier trx id is written.
Definition: lob0index.h:425
byte * get_pageno_ptr() const
Get pointer to location where page number is written.
Definition: lob0index.h:432
byte * m_node
Pointer to the blob index entry node.
Definition: lob0index.h:445
byte * get_versions_ptr() const
Get pointer to the base node of the list of versions.
Definition: lob0index.h:413
byte * get_datalen_ptr() const
Get the location where data length is stored.
Definition: lob0index.h:417
byte * get_trxid_ptr() const
Get pointer to the location where the creator trx id is written.
Definition: lob0index.h:421
The node page (also can be called as the index page) contains a list of index_entry_t objects.
Definition: lob0impl.h:495
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:142
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
unsigned long int ulint
Definition: univ.i:406
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105