MySQL 8.0.31
Source Code Documentation
lob0pages.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2016, 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#ifndef lob0pages_h
27#define lob0pages_h
28
29#include "lob0first.h"
30
31namespace lob {
32
33/** The LOB data page carrying the user data. */
34struct data_page_t : public basic_page_t {
38 static const ulint LOB_PAGE_DATA = OFFSET_TRX_ID + 6;
39
40 data_page_t() = default;
41
42 /** Constructor. */
43 data_page_t(buf_block_t *block, mtr_t *mtr) : basic_page_t(block, mtr) {
46 }
47
49 : basic_page_t(block, mtr, index) {}
50
52 : basic_page_t(nullptr, mtr, index) {}
53
54 /** Constructor.
55 @param[in] block the buffer block.*/
57
58 /** Allocate a LOB data page.
59 @param[in] alloc_mtr Mini-transaction to be used for allocation of LOB page.
60 @param[in] is_bulk true if bulk operation.
61 @return allocated buffer block or nullptr */
62 buf_block_t *alloc(mtr_t *alloc_mtr, bool is_bulk);
63
65
68 }
69
70 void dealloc() {
72 m_block = nullptr;
73 }
74
76 ut_ad(m_mtr != nullptr);
77
80 }
81
83 byte *ptr = frame() + OFFSET_TRX_ID;
84 mach_write_to_6(ptr, id);
85 mlog_log_string(ptr, 6, m_mtr);
86 }
87
88 /** Write the trx identifier to the header, without
89 generating redo log.
90 @param[in] id the transaction identifier.*/
92 byte *ptr = frame() + OFFSET_TRX_ID;
93 mach_write_to_6(ptr, id);
94 }
95
96 static ulint payload() {
98 }
99
100 byte *data_begin() const { return (frame() + LOB_PAGE_DATA); }
101
102 /** Create a new data page and replace some or all parts of the old data
103 with data.
104 @param[in] trx Current transaction.
105 @param[in] offset Offset where replace begins.
106 @param[in,out] ptr Pointer to new data.
107 @param[in] want Amount of data the caller wants to replace.
108 @param[in] mtr Mini-transaction context.
109 @return the buffer block of the new data page. */
110 buf_block_t *replace(trx_t *trx, ulint offset, const byte *&ptr, ulint &want,
111 mtr_t *mtr);
112
113 /** Replace some or all parts of the data inline.
114 @param[in] offset Offset where replace begins.
115 @param[in,out] ptr Pointer to new data.
116 @param[in] want Amount of data the caller wants to replace.
117 @param[in] mtr Mini-transaction context. */
118 void replace_inline(ulint offset, const byte *&ptr, ulint &want, mtr_t *mtr);
119
122 }
123
124 void set_data_len(ulint len) {
125 ut_ad(m_mtr != nullptr);
126
128 }
129
130 /** Read data from the data page.
131 @param[in] offset read begins at this offset.
132 @param[out] ptr the output buffer.
133 @param[in] want bytes to read
134 @return bytes actually read. */
135 ulint read(ulint offset, byte *ptr, ulint want);
136
137 /** Write data into a data page.
138 @param[in,out] data the data to be written. it will be updated to
139 point to the byte not yet written.
140 @param[in,out] len length of data to be written.
141 @return amount of data actually written into the page. */
142 ulint write(const byte *&data, ulint &len);
143
144 /** Append given data in data page.
145 @param[in] trxid transaction doing append.
146 @param[in,out] data data to be appended.
147 @param[in,out] len length of data.
148 @return number of bytes appended. */
149 ulint append(trx_id_t trxid, byte *&data, ulint &len);
150
151 std::pair<ulint, byte *> insert_middle(trx_t *trx, ulint offset, byte *&data,
152 ulint &len, buf_block_t *&new_block);
153
155
156 ulint max_space_available() const { return (payload()); }
157
158 ulint space_left() const;
159};
160
161} /* namespace lob */
162
163#endif /* lob0pages_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:48
void btr_page_free_low(dict_index_t *index, buf_block_t *block, ulint level, mtr_t *mtr)
Frees a file page used in an index tree.
Definition: btr0btr.cc:527
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
constexpr page_type_t FIL_PAGE_TYPE_LOB_DATA
Data pages of uncompressed LOB.
Definition: fil0fil.h:1268
uint16_t page_type_t
Definition: fil0fil.h:1184
constexpr uint32_t FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:75
constexpr uint32_t FIL_PAGE_DATA
start of the data on the page
Definition: fil0types.h:110
constexpr uint32_t FIL_PAGE_DATA_END
size of the page trailer
Definition: fil0types.h:118
static uint32_t mach_read_from_4(const byte *b)
The following function is used to fetch data from 4 consecutive bytes.
static void mach_write_to_6(byte *b, uint64_t id)
The following function is used to store data in 6 consecutive bytes.
void mlog_log_string(byte *ptr, ulint len, mtr_t *mtr)
Logs a write of a string to a file page buffered in the buffer pool.
Definition: mtr0log.cc:341
void mlog_write_ulint(byte *ptr, ulint val, mlog_id_t type, mtr_t *mtr)
Writes 1, 2 or 4 bytes to a file page.
Definition: mtr0log.cc:255
@ MLOG_4BYTES
4 bytes ...
Definition: mtr0types.h:75
@ MLOG_1BYTE
one byte is written
Definition: mtr0types.h:69
@ MLOG_2BYTES
2 bytes ...
Definition: mtr0types.h:72
Provides the large objects (LOB) module.
Definition: lob0del.h:31
required string type
Definition: replication_group_member_actions.proto:33
The buffer control block structure.
Definition: buf0buf.h:1664
Data structure for an index.
Definition: dict0mem.h:1021
Definition: lob0util.h:41
mtr_t * m_mtr
Definition: lob0util.h:128
dict_index_t * m_index
Definition: lob0util.h:129
page_type_t get_page_type() const
Definition: lob0util.h:94
buf_block_t * m_block
Definition: lob0util.h:127
byte * frame() const
Definition: lob0util.h:98
The LOB data page carrying the user data.
Definition: lob0pages.h:34
buf_block_t * remove_middle(trx_t *trx, ulint offset, ulint &len)
data_page_t()=default
ulint read(ulint offset, byte *ptr, ulint want)
Read data from the data page.
Definition: lob0pages.cc:201
void set_trx_id_no_redo(trx_id_t id)
Write the trx identifier to the header, without generating redo log.
Definition: lob0pages.h:91
ulint append(trx_id_t trxid, byte *&data, ulint &len)
Append given data in data page.
Definition: lob0pages.cc:115
static const ulint OFFSET_VERSION
Definition: lob0pages.h:35
buf_block_t * alloc(mtr_t *alloc_mtr, bool is_bulk)
Allocate a LOB data page.
Definition: lob0pages.cc:142
data_page_t(buf_block_t *block, mtr_t *mtr, dict_index_t *index)
Definition: lob0pages.h:48
void replace_inline(ulint offset, const byte *&ptr, ulint &want, mtr_t *mtr)
Replace some or all parts of the data inline.
Definition: lob0pages.cc:34
ulint write(const byte *&data, ulint &len)
Write data into a data page.
Definition: lob0pages.cc:169
static ulint payload()
Definition: lob0pages.h:96
buf_block_t * replace(trx_t *trx, ulint offset, const byte *&ptr, ulint &want, mtr_t *mtr)
Create a new data page and replace some or all parts of the old data with data.
Definition: lob0pages.cc:58
static const ulint OFFSET_TRX_ID
Definition: lob0pages.h:37
void set_data_len(ulint len)
Definition: lob0pages.h:124
ulint max_space_available() const
Definition: lob0pages.h:156
data_page_t(mtr_t *mtr, dict_index_t *index)
Definition: lob0pages.h:51
std::pair< ulint, byte * > insert_middle(trx_t *trx, ulint offset, byte *&data, ulint &len, buf_block_t *&new_block)
void dealloc()
Definition: lob0pages.h:70
ulint space_left() const
Definition: lob0pages.cc:140
static const ulint LOB_PAGE_DATA
Definition: lob0pages.h:38
static const ulint OFFSET_DATA_LEN
Definition: lob0pages.h:36
void set_version_0()
Definition: lob0pages.h:66
void set_page_type()
Definition: lob0pages.h:75
void set_trx_id(trx_id_t id)
Definition: lob0pages.h:82
data_page_t(buf_block_t *block, mtr_t *mtr)
Constructor.
Definition: lob0pages.h:43
ulint get_data_len() const
Definition: lob0pages.h:120
byte * data_begin() const
Definition: lob0pages.h:100
data_page_t(buf_block_t *block)
Constructor.
Definition: lob0pages.h:56
buf_block_t * load_x(page_no_t page_no)
Definition: lob0pages.cc:183
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:181
Definition: trx0trx.h:680
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:137
#define UNIV_PAGE_SIZE
The universal page size of the database.
Definition: univ.i:295
unsigned long int ulint
Definition: univ.i:407
constexpr ulint ULINT_UNDEFINED
The 'undefined' value for a ulint.
Definition: univ.i:421
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:56