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