MySQL 8.0.32
Source Code Documentation
lob0util.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 lob0util_h
27#define lob0util_h
28
29#include <stdint.h>
30
31#include "buf0buf.h"
32#include "fil0fil.h"
33#include "fut0lst.h"
34
35namespace lob {
36
37/** Number of times an LOB can be partially updated. Once this limit is
38reached, then the LOB will be fully updated. */
39const uint32_t MAX_PARTIAL_UPDATE_LIMIT = 1000;
40
43
45 : m_block(block), m_mtr(mtr), m_index(nullptr) {}
46
48 : m_block(block), m_mtr(mtr), m_index(index) {}
49
50 /** Update the space identifier to given value without generating
51 any redo log records.
52 @param[in] space_id the space identifier. */
55 }
56
57 /** Get page number of the current page.
58 @return the page number of the current page. */
60 ut_ad(m_block != nullptr);
61 return (m_block->page.id.page_no());
62 }
63
64 /** Get the page id of the current page.
65 @return the page id of current page. */
67 ut_ad(m_block != nullptr);
68 return (m_block->page.id);
69 }
70
71 /** Set the FIL_PAGE_NEXT to the given page number, using the given mini
72 transaction context.
73 @param[in] page_no The page number to set.
74 @param[in] mtr The mini-transaction context. */
75 void set_next_page(page_no_t page_no, mtr_t *mtr) {
77 }
78
79 /** Set the FIL_PAGE_NEXT to the given page number.
80 @param[in] page_no The page number to set. */
81 void set_next_page(page_no_t page_no) { set_next_page(page_no, m_mtr); }
82
83 /** Set the FIL_PAGE_NEXT to FIL_NULL. */
85 ut_ad(m_mtr != nullptr);
86
88 }
89
92 }
93
96 }
97
98 byte *frame() const { return (buf_block_get_frame(m_block)); }
99
101 ut_ad(!addr.is_null());
102
103 flst_node_t *node = nullptr;
104 if (addr.page == get_page_no()) {
105 node = frame() + addr.boffset;
106 }
107 return (node);
108 }
109
110 static ulint payload();
112
113 /** Get the underlying buffer block.
114 @return the buffer block. */
115 [[nodiscard]] buf_block_t *get_block() const noexcept;
116
117 void set_block(buf_block_t *block) {
120
121 m_block = block;
122 }
123
124 void set_mtr(mtr_t *mtr) { m_mtr = mtr; }
125
126 protected:
130};
131
132[[nodiscard]] inline buf_block_t *basic_page_t::get_block() const noexcept {
133 return m_block;
134}
135
136/** Allocate one LOB page.
137@param[in] index Index in which LOB exists.
138@param[in] lob_mtr Mini-transaction context.
139@param[in] hint Hint page number for allocation.
140@param[in] bulk true if operation is OPCODE_INSERT_BULK,
141 false otherwise.
142@return the allocated block of the BLOB page or nullptr. */
144 bool bulk);
145
146/** Check if the index entry is visible to the given transaction.
147@param[in] index the index to which LOB belongs.
148@param[in] trx the transaction reading the index entry.
149@param[in] entry_trx_id the trx id in the index entry. */
150bool entry_visible_to(dict_index_t *index, trx_t *trx, trx_id_t entry_trx_id);
151
152} /* namespace lob */
153
154#endif /* lob0util_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
uint32_t page_no_t
Page number.
Definition: api0api.h:48
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:206
page_no_t page_no() const
Retrieve the page number.
Definition: buf0types.h:242
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
The low-level file system.
uint16_t page_type_t
Definition: fil0fil.h:1184
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:1122
constexpr uint32_t FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:75
constexpr uint32_t FIL_PAGE_SPACE_ID
alias for space id
Definition: fil0types.h:107
constexpr uint32_t FIL_PAGE_NEXT
if there is a 'natural' successor of the page, its offset.
Definition: fil0types.h:60
File-based list utilities.
byte flst_node_t
Definition: fut0lst.h:46
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:255
#define mtr_memo_contains(m, o, t)
Check if memo contains the given item.
Definition: mtr0mtr.h:106
@ MLOG_4BYTES
4 bytes ...
Definition: mtr0types.h:75
@ MTR_MEMO_PAGE_X_FIX
Definition: mtr0types.h:272
@ MTR_MEMO_PAGE_S_FIX
Definition: mtr0types.h:270
Provides the large objects (LOB) module.
Definition: lob0del.h:31
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:39
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:46
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:1045
File space address.
Definition: fil0fil.h:1139
uint32_t boffset
Byte offset within the page.
Definition: fil0fil.h:1171
page_no_t page
Page number within a space.
Definition: fil0fil.h:1168
bool is_null() const
Check if the file address is null.
Definition: fil0fil.h:1157
Definition: lob0util.h:41
basic_page_t(buf_block_t *block, mtr_t *mtr)
Definition: lob0util.h:44
mtr_t * m_mtr
Definition: lob0util.h:128
buf_block_t * get_block() const noexcept
Get the underlying buffer block.
Definition: lob0util.h:132
basic_page_t(buf_block_t *block, mtr_t *mtr, dict_index_t *index)
Definition: lob0util.h:47
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
page_no_t get_page_no() const
Get page number of the current page.
Definition: lob0util.h:59
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:53
page_id_t get_page_id() const
Get the page id of the current page.
Definition: lob0util.h:66
page_no_t get_next_page()
Definition: lob0util.h:90
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:75
basic_page_t()
Definition: lob0util.h:42
void set_mtr(mtr_t *mtr)
Definition: lob0util.h:124
void set_block(buf_block_t *block)
Definition: lob0util.h:117
void set_next_page_null()
Set the FIL_PAGE_NEXT to FIL_NULL.
Definition: lob0util.h:84
void set_next_page(page_no_t page_no)
Set the FIL_PAGE_NEXT to the given page number.
Definition: lob0util.h:81
ulint max_space_available()
flst_node_t * get_flst_node(const fil_addr_t &addr)
Definition: lob0util.h:100
byte * frame() const
Definition: lob0util.h:98
static ulint payload()
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
unsigned long int ulint
Definition: univ.i:407
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68