MySQL 9.1.0
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#include "lob0impl.h"
32
33namespace lob {
34
35/** The LOB data page carrying the user data. */
36struct data_page_t : public basic_page_t {
40 static const ulint LOB_PAGE_DATA = OFFSET_TRX_ID + 6;
41
42 data_page_t() = default;
43
44 /** Constructor. */
45 data_page_t(buf_block_t *block, mtr_t *mtr) : basic_page_t(block, mtr) {
48 }
49
51 : basic_page_t(block, mtr, index) {}
52
54 : basic_page_t(nullptr, mtr, index) {}
55
56 /** Constructor.
57 @param[in] block the buffer block.*/
59
60 /** Allocate a LOB data page.
61 @param[in] alloc_mtr Mini-transaction to be used for allocation of LOB page.
62 @param[in] is_bulk true if bulk operation.
63 @return allocated buffer block or nullptr */
64 buf_block_t *alloc(mtr_t *alloc_mtr, bool is_bulk);
65
67
70 }
71
72 void dealloc() {
74 m_block = nullptr;
75 }
76
78 ut_ad(m_mtr != nullptr);
79
82 }
83
85 byte *ptr = frame() + OFFSET_TRX_ID;
86 mach_write_to_6(ptr, id);
87 mlog_log_string(ptr, 6, m_mtr);
88 }
89
90 /** Write the trx identifier to the header, without
91 generating redo log.
92 @param[in] id the transaction identifier.*/
94 byte *ptr = frame() + OFFSET_TRX_ID;
95 mach_write_to_6(ptr, id);
96 }
97
98 static ulint payload() {
100 }
101
102 byte *data_begin() const { return (frame() + LOB_PAGE_DATA); }
103
104 /** Create a new data page and replace some or all parts of the old data
105 with data.
106 @param[in] trx Current transaction.
107 @param[in] offset Offset where replace begins.
108 @param[in,out] ptr Pointer to new data.
109 @param[in] want Amount of data the caller wants to replace.
110 @param[in] mtr Mini-transaction context.
111 @return the buffer block of the new data page. */
112 buf_block_t *replace(trx_t *trx, ulint offset, const byte *&ptr, ulint &want,
113 mtr_t *mtr);
114
115 /** Replace some or all parts of the data inline.
116 @param[in] offset Offset where replace begins.
117 @param[in,out] ptr Pointer to new data.
118 @param[in] want Amount of data the caller wants to replace.
119 @param[in] mtr Mini-transaction context. */
120 void replace_inline(ulint offset, const byte *&ptr, ulint &want, mtr_t *mtr);
121
124 }
125
126 void set_data_len(ulint len) {
127 ut_ad(m_mtr != nullptr);
128
130 }
131
132 /** Read data from the data page.
133 @param[in] offset read begins at this offset.
134 @param[out] ptr the output buffer.
135 @param[in] want bytes to read
136 @return bytes actually read. */
137 ulint read(ulint offset, byte *ptr, ulint want);
138
139 /** Write data into a data page.
140 @param[in,out] data the data to be written. it will be updated to
141 point to the byte not yet written.
142 @param[in,out] len length of data to be written.
143 @return amount of data actually written into the page. */
144 ulint write(const byte *&data, ulint &len);
145
146 /** Append given data in data page.
147 @param[in] trxid transaction doing append.
148 @param[in,out] data data to be appended.
149 @param[in,out] len length of data.
150 @return number of bytes appended. */
151 ulint append(trx_id_t trxid, byte *&data, ulint &len);
152
153 std::pair<ulint, byte *> insert_middle(trx_t *trx, ulint offset, byte *&data,
154 ulint &len, buf_block_t *&new_block);
155
157
158 ulint max_space_available() const { return (payload()); }
159
160 ulint space_left() const;
161};
162
163} /* namespace lob */
164
165#endif /* lob0pages_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:46
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:1302
uint16_t page_type_t
Definition: fil0fil.h:1218
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: lob0bulk.h:44
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:1041
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:36
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:93
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:37
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:50
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:98
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:39
void set_data_len(ulint len)
Definition: lob0pages.h:126
ulint max_space_available() const
Definition: lob0pages.h:158
data_page_t(mtr_t *mtr, dict_index_t *index)
Definition: lob0pages.h:53
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:72
ulint space_left() const
Definition: lob0pages.cc:141
static const ulint LOB_PAGE_DATA
Definition: lob0pages.h:40
static const ulint OFFSET_DATA_LEN
Definition: lob0pages.h:38
void set_version_0()
Definition: lob0pages.h:68
void set_page_type()
Definition: lob0pages.h:77
void set_trx_id(trx_id_t id)
Definition: lob0pages.h:84
data_page_t(buf_block_t *block, mtr_t *mtr)
Constructor.
Definition: lob0pages.h:45
ulint get_data_len() const
Definition: lob0pages.h:122
byte * data_begin() const
Definition: lob0pages.h:102
data_page_t(buf_block_t *block)
Constructor.
Definition: lob0pages.h:58
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:675
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