MySQL 8.0.40
Source Code Documentation
lob0util.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 lob0util_h
28#define lob0util_h
29
30#include <stdint.h>
31
32#include "buf0buf.h"
33#include "fil0fil.h"
34#include "fut0lst.h"
35
36namespace lob {
37
38/** Number of times an LOB can be partially updated. Once this limit is
39reached, then the LOB will be fully updated. */
40const uint32_t MAX_PARTIAL_UPDATE_LIMIT = 1000;
41
44
46 : m_block(block), m_mtr(mtr), m_index(nullptr) {}
47
49 : m_block(block), m_mtr(mtr), m_index(index) {}
50
51 /** Update the space identifier to given value without generating
52 any redo log records.
53 @param[in] space_id the space identifier. */
56 }
57
58 /** Get page number of the current page.
59 @return the page number of the current page. */
61 ut_ad(m_block != nullptr);
62 return (m_block->page.id.page_no());
63 }
64
65 /** Get the page id of the current page.
66 @return the page id of current page. */
68 ut_ad(m_block != nullptr);
69 return (m_block->page.id);
70 }
71
72 /** Set the FIL_PAGE_NEXT to the given page number, using the given mini
73 transaction context.
74 @param[in] page_no The page number to set.
75 @param[in] mtr The mini-transaction context. */
76 void set_next_page(page_no_t page_no, mtr_t *mtr) {
78 }
79
80 /** Set the FIL_PAGE_NEXT to the given page number.
81 @param[in] page_no The page number to set. */
82 void set_next_page(page_no_t page_no) { set_next_page(page_no, m_mtr); }
83
84 /** Set the FIL_PAGE_NEXT to FIL_NULL. */
86 ut_ad(m_mtr != nullptr);
87
89 }
90
93 }
94
97 }
98
99 byte *frame() const { return (buf_block_get_frame(m_block)); }
100
102 ut_ad(!addr.is_null());
103
104 flst_node_t *node = nullptr;
105 if (addr.page == get_page_no()) {
106 node = frame() + addr.boffset;
107 }
108 return (node);
109 }
110
111 static ulint payload();
113
114 /** Get the underlying buffer block.
115 @return the buffer block. */
116 [[nodiscard]] buf_block_t *get_block() const noexcept;
117
118 void set_block(buf_block_t *block) {
121
122 m_block = block;
123 }
124
125 void set_mtr(mtr_t *mtr) { m_mtr = mtr; }
126
127 protected:
131};
132
133[[nodiscard]] inline buf_block_t *basic_page_t::get_block() const noexcept {
134 return m_block;
135}
136
137/** Allocate one LOB page.
138@param[in] index Index in which LOB exists.
139@param[in] lob_mtr Mini-transaction context.
140@param[in] hint Hint page number for allocation.
141@param[in] bulk true if operation is OPCODE_INSERT_BULK,
142 false otherwise.
143@return the allocated block of the BLOB page or nullptr. */
145 bool bulk);
146
147/** Check if the index entry is visible to the given transaction.
148@param[in] index the index to which LOB belongs.
149@param[in] trx the transaction reading the index entry.
150@param[in] entry_trx_id the trx id in the index entry. */
151bool entry_visible_to(dict_index_t *index, trx_t *trx, trx_id_t entry_trx_id);
152
153} /* namespace lob */
154
155#endif /* lob0util_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:52
uint32_t page_no_t
Page number.
Definition: api0api.h:50
The database buffer pool high-level routines.
static buf_frame_t * buf_block_get_frame(const buf_block_t *block)
Gets a pointer to the memory frame of a block.
page_id_t id
Page id.
Definition: buf0buf.h:1319
Page identifier.
Definition: buf0types.h:207
page_no_t page_no() const
Retrieve the page number.
Definition: buf0types.h:243
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
The low-level file system.
uint16_t page_type_t
Definition: fil0fil.h:1193
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:1131
constexpr uint32_t FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:76
constexpr uint32_t FIL_PAGE_SPACE_ID
alias for space id
Definition: fil0types.h:108
constexpr uint32_t FIL_PAGE_NEXT
if there is a 'natural' successor of the page, its offset.
Definition: fil0types.h:61
File-based list utilities.
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 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_4(byte *b, ulint n)
The following function is used to store data in 4 consecutive bytes.
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:256
#define mtr_memo_contains(m, o, t)
Check if memo contains the given item.
Definition: mtr0mtr.h:107
@ MLOG_4BYTES
4 bytes ...
Definition: mtr0types.h:76
@ MTR_MEMO_PAGE_X_FIX
Definition: mtr0types.h:273
@ MTR_MEMO_PAGE_S_FIX
Definition: mtr0types.h:271
Provides the large objects (LOB) module.
Definition: lob0del.h:32
bool entry_visible_to(dict_index_t *index, trx_t *trx, trx_id_t entry_trx_id)
Check if the index entry is visible to the given transaction.
const uint32_t MAX_PARTIAL_UPDATE_LIMIT
Number of times an LOB can be partially updated.
Definition: lob0util.h:40
buf_block_t * alloc_lob_page(dict_index_t *index, mtr_t *lob_mtr, page_no_t hint, bool bulk)
Allocate one LOB page.
Definition: lob0util.cc:47
The buffer control block structure.
Definition: buf0buf.h:1690
buf_page_t page
page information; this must be the first field, so that buf_pool->page_hash can point to buf_page_t o...
Definition: buf0buf.h:1696
Data structure for an index.
Definition: dict0mem.h:1046
File space address.
Definition: fil0fil.h:1148
uint32_t boffset
Byte offset within the page.
Definition: fil0fil.h:1180
page_no_t page
Page number within a space.
Definition: fil0fil.h:1177
bool is_null() const
Check if the file address is null.
Definition: fil0fil.h:1166
Definition: lob0util.h:42
basic_page_t(buf_block_t *block, mtr_t *mtr)
Definition: lob0util.h:45
mtr_t * m_mtr
Definition: lob0util.h:129
buf_block_t * get_block() const noexcept
Get the underlying buffer block.
Definition: lob0util.h:133
basic_page_t(buf_block_t *block, mtr_t *mtr, dict_index_t *index)
Definition: lob0util.h:48
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
page_no_t get_page_no() const
Get page number of the current page.
Definition: lob0util.h:60
void set_space_id_no_redo(space_id_t space_id)
Update the space identifier to given value without generating any redo log records.
Definition: lob0util.h:54
page_id_t get_page_id() const
Get the page id of the current page.
Definition: lob0util.h:67
page_no_t get_next_page()
Definition: lob0util.h:91
void set_next_page(page_no_t page_no, mtr_t *mtr)
Set the FIL_PAGE_NEXT to the given page number, using the given mini transaction context.
Definition: lob0util.h:76
basic_page_t()
Definition: lob0util.h:43
void set_mtr(mtr_t *mtr)
Definition: lob0util.h:125
void set_block(buf_block_t *block)
Definition: lob0util.h:118
void set_next_page_null()
Set the FIL_PAGE_NEXT to FIL_NULL.
Definition: lob0util.h:85
void set_next_page(page_no_t page_no)
Set the FIL_PAGE_NEXT to the given page number.
Definition: lob0util.h:82
ulint max_space_available()
flst_node_t * get_flst_node(const fil_addr_t &addr)
Definition: lob0util.h:101
byte * frame() const
Definition: lob0util.h:99
static ulint payload()
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
unsigned long int ulint
Definition: univ.i:406
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69