MySQL  8.0.23
Source Code Documentation
lob0inf.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2016, 2020, Oracle and/or its affiliates.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 #ifndef lob0inf_h
27 #define lob0inf_h
28 
29 #include <list>
30 
31 #include "fut0lst.h"
32 #include "lob0index.h"
33 #include "lob0lob.h"
34 #include "mtr0mtr.h"
35 #include "table.h"
36 #include "trx0trx.h"
37 
38 struct lob_diff_t;
39 
40 namespace lob {
41 
42 /** Insert a large object (LOB) into the system.
43 @param[in] ctx the B-tree context for this LOB operation.
44 @param[in] trx transaction doing the insertion.
45 @param[in,out] ref the LOB reference.
46 @param[in] field the LOB field.
47 @param[in] field_j the LOB field index in big rec vector.
48 @return DB_SUCCESS on success, error code on failure.*/
49 dberr_t insert(InsertContext *ctx, trx_t *trx, ref_t &ref,
50  big_rec_field_t *field, ulint field_j);
51 
52 /** Insert a compressed large object (LOB) into the system.
53 @param[in] ctx the B-tree context for this LOB operation.
54 @param[in] trx transaction doing the insertion.
55 @param[in,out] ref the LOB reference.
56 @param[in] field the LOB field.
57 @param[in] field_j the LOB field index in big rec vector.
58 @return DB_SUCCESS on success, error code on failure.*/
59 dberr_t z_insert(InsertContext *ctx, trx_t *trx, ref_t &ref,
60  big_rec_field_t *field, ulint field_j);
61 
62 /** Fetch a large object (LOB) from the system.
63 @param[in] ctx the read context information.
64 @param[in] ref the LOB reference identifying the LOB.
65 @param[in] offset read the LOB from the given offset.
66 @param[in] len the length of LOB data that needs to be fetched.
67 @param[out] buf the output buffer (owned by caller) of minimum len bytes.
68 @return the amount of data (in bytes) that was actually read. */
69 ulint read(ReadContext *ctx, ref_t ref, ulint offset, ulint len, byte *buf);
70 
71 /** Fetch a compressed large object (ZLOB) from the system.
72 @param[in] ctx the read context information.
73 @param[in] ref the LOB reference identifying the LOB.
74 @param[in] offset read the LOB from the given offset.
75 @param[in] len the length of LOB data that needs to be fetched.
76 @param[out] buf the output buffer (owned by caller) of minimum len bytes.
77 @return the amount of data (in bytes) that was actually read. */
78 ulint z_read(lob::ReadContext *ctx, lob::ref_t ref, ulint offset, ulint len,
79  byte *buf);
80 
81 /** Print information about the given LOB.
82 @param[in] trx the current transaction.
83 @param[in] index the clust index that contains the LOB.
84 @param[in] out the output stream into which LOB info is printed.
85 @param[in] ref the LOB reference
86 @param[in] fatal if true assert at end of function. */
87 void print(trx_t *trx, dict_index_t *index, std::ostream &out, ref_t ref,
88  bool fatal);
89 
90 /** Print information about the given compressed lob. */
91 dberr_t z_print_info(const dict_index_t *index, const lob::ref_t &ref,
92  std::ostream &out);
93 
94 /** Update a portion of the given LOB.
95 @param[in] trx the transaction that is doing the modification.
96 @param[in] index the clustered index containing the LOB.
97 @param[in] upd update vector
98 @param[in] field_no the LOB field number
99 @return DB_SUCCESS on success, error code on failure. */
100 dberr_t update(trx_t *trx, dict_index_t *index, const upd_t *upd,
101  ulint field_no);
102 
103 /** Update a portion of the given LOB.
104 @param[in] trx the transaction that is doing the modification.
105 @param[in] index the clustered index containing the LOB.
106 @param[in] upd update vector
107 @param[in] field_no the LOB field number
108 @return DB_SUCCESS on success, error code on failure. */
109 dberr_t z_update(trx_t *trx, dict_index_t *index, const upd_t *upd,
110  ulint field_no);
111 
112 /** Get the list of index entries affected by the given partial update
113 vector.
114 @param[in] ref LOB reference object.
115 @param[in] index Clustered index to which LOB belongs.
116 @param[in] bdiff Single partial update vector
117 @param[out] entries Affected LOB index entries.
118 @param[in] mtr Mini-transaction
119 @return DB_SUCCESS on success, error code on failure. */
121  const Binary_diff &bdiff,
122  List_iem_t &entries, mtr_t *mtr);
123 
124 /** Apply the undo log on the LOB
125 @param[in] mtr Mini-transaction context.
126 @param[in] trx Transaction that is being rolled back.
127 @param[in] index Clustered index to which LOB belongs.
128 @param[in] ref LOB reference object.
129 @param[in] uf Update vector for LOB field.
130 @return DB_SUCCESS on success, error code on failure. */
131 dberr_t apply_undolog(mtr_t *mtr, trx_t *trx, dict_index_t *index, ref_t ref,
132  const upd_field_t *uf);
133 
134 /** Get information about the given LOB.
135 @param[in] ref LOB reference.
136 @param[in] index Clustered index to which LOB belongs.
137 @param[out] lob_version LOB version number.
138 @param[out] last_trx_id trx_id that modified the lob last.
139 @param[out] last_undo_no Trx undo no that modified the lob last.
140 @param[out] page_type the Page type of first lob page.
141 @param[in] mtr Mini-transaction context.
142 @return always returns DB_SUCCESS. */
143 dberr_t get_info(ref_t &ref, dict_index_t *index, ulint &lob_version,
144  trx_id_t &last_trx_id, undo_no_t &last_undo_no,
145  page_type_t &page_type, mtr_t *mtr);
146 
147 /** Validate the size of the given LOB.
148 @param[in] lob_size Expected size of the LOB, mostly obtained from
149  the LOB reference.
150 @param[in] index Clustered index containing the LOB.
151 @param[in] node_loc Location of the first LOB index entry.
152 @param[in] mtr Mini-transaction context.
153 @return true if size is valid, false otherwise. */
154 bool validate_size(const ulint lob_size, dict_index_t *index,
155  fil_addr_t node_loc, mtr_t *mtr);
156 
157 } // namespace lob
158 
159 #endif // lob0inf_h
upd_field_t
Definition: row0upd.h:486
lob::z_print_info
dberr_t z_print_info(const dict_index_t *index, const lob::ref_t &ref, std::ostream &out)
Print information about the given compressed lob.
Definition: lob0impl.cc:567
undo_no_t
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:148
lob::ReadContext
The context information for reading a single BLOB.
Definition: lob0lob.h:1193
lob::validate_size
bool validate_size(const ulint lob_size, dict_index_t *index, fil_addr_t node_loc, mtr_t *mtr)
Validate the size of the given LOB.
Definition: lob0update.cc:198
lob::z_update
dberr_t z_update(trx_t *trx, dict_index_t *index, const upd_t *upd, ulint field_no)
Update a portion of the given LOB.
trx_id_t
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
dict_index_t
Data structure for an index.
Definition: dict0mem.h:879
mtr_t
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
lob::print
void print(trx_t *trx, dict_index_t *index, std::ostream &out, ref_t ref, bool fatal)
Print information about the given LOB.
Definition: lob0impl.cc:1364
dberr_t
dberr_t
Definition: db0err.h:38
lob::insert
dberr_t insert(InsertContext *ctx, trx_t *trx, ref_t &ref, big_rec_field_t *field, ulint field_j)
Insert a large object (LOB) into the system.
Definition: lob0impl.cc:962
lob::update
dberr_t update(trx_t *trx, dict_index_t *index, const upd_t *upd, ulint field_no)
Update a portion of the given LOB.
lob::apply_undolog
dberr_t apply_undolog(mtr_t *mtr, trx_t *trx, dict_index_t *index, ref_t ref, const upd_field_t *uf)
Apply the undo log on the LOB.
Definition: lob0update.cc:629
lob::ref_t
The struct 'lob::ref_t' represents an external field reference.
Definition: lob0lob.h:197
lob::z_insert
dberr_t z_insert(InsertContext *ctx, trx_t *trx, ref_t &ref, big_rec_field_t *field, ulint field_j)
Insert a compressed large object (LOB) into the system.
Definition: lob0impl.cc:438
lob::get_affected_index_entries
dberr_t get_affected_index_entries(const ref_t &ref, dict_index_t *index, const Binary_diff &bdiff, List_iem_t &entries, mtr_t *mtr)
Get the list of index entries affected by the given partial update vector.
Definition: lob0util.cc:113
big_rec_field_t
A slot for a field in a big rec vector.
Definition: data0data.h:816
buf
Definition: buf0block_hint.cc:29
lob::read
ulint read(ReadContext *ctx, ref_t ref, ulint offset, ulint len, byte *buf)
Fetch a large object (LOB) from the system.
Definition: lob0impl.cc:1107
lob::List_iem_t
std::list< index_entry_mem_t > List_iem_t
List of index entry memory (iem) objects.
Definition: lob0index.h:91
page_type_t
uint16_t page_type_t
Definition: fil0fil.h:1199
table.h
upd_t
Definition: row0upd.h:580
fut0lst.h
mtr0mtr.h
lob::z_read
ulint z_read(lob::ReadContext *ctx, lob::ref_t ref, ulint offset, ulint len, byte *buf)
Fetch a compressed large object (ZLOB) from the system.
Definition: zlob0read.cc:70
Binary_diff
Class that represents a single change to a column value in partial update of a JSON column.
Definition: table.h:1281
trx0trx.h
lob0lob.h
Implements the large objects (LOB) module.
fil_addr_t
File space address.
Definition: fil0fil.h:1154
lob0index.h
lob
Provides the large objects (LOB) module.
Definition: lob0del.h:31
trx_t
Definition: trx0trx.h:836
lob::get_info
dberr_t get_info(ref_t &ref, dict_index_t *index, ulint &lob_version, trx_id_t &last_trx_id, undo_no_t &last_undo_no, page_type_t &page_type, mtr_t *mtr)
Get information about the given LOB.
Definition: lob0util.cc:206