Debian Codegraph @

storage/innobase/include/lob0inf.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 2016, 2026, 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 designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27 #ifndef lob0inf_h
28 #define lob0inf_h
29
30 #include <list>
31
32 #include "fut0lst.h"
33 #include "lob0index.h"
34 #include "lob0lob.h"
35 #include "mtr0mtr.h"
36 #include "table.h"
37 #include "trx0trx.h"
38
39 struct lob_diff_t;
40
41 namespace lob {
42
43 /** Insert a large object (LOB) into the system.
44 @param[in] ctx the B-tree context for this LOB operation.
45 @param[in] trx transaction doing the insertion.
46 @param[in,out] ref the LOB reference.
47 @param[in] field the LOB field.
48 @param[in] field_j the LOB field index in big rec vector.
49 @return DB_SUCCESS on success, error code on failure.*/
50 dberr_t insert(InsertContext *ctx, trx_t *trx, ref_t &ref,
51 big_rec_field_t *field, ulint field_j);
52
53 /** Insert a compressed large object (LOB) into the system.
54 @param[in] ctx the B-tree context for this LOB operation.
55 @param[in] trx transaction doing the insertion.
56 @param[in,out] ref the LOB reference.
57 @param[in] field the LOB field.
58 @param[in] field_j the LOB field index in big rec vector.
59 @return DB_SUCCESS on success, error code on failure.*/
60 dberr_t z_insert(InsertContext *ctx, trx_t *trx, ref_t &ref,
61 big_rec_field_t *field, ulint field_j);
62
63 /** Fetch a large object (LOB) from the system.
64 @param[in] ctx the read context information.
65 @param[in] ref the LOB reference identifying the LOB.
66 @param[in] offset read the LOB from the given offset.
67 @param[in] len the length of LOB data that needs to be fetched.
68 @param[out] buf the output buffer (owned by caller) of minimum len bytes.
69 @return the amount of data (in bytes) that was actually read. */
70 ulint read(ReadContext *ctx, ref_t ref, ulint offset, ulint len, byte *buf);
71
72 /** Fetch a compressed large object (ZLOB) from the system.
73 @param[in] ctx the read context information.
74 @param[in] ref the LOB reference identifying the LOB.
75 @param[in] offset read the LOB from the given offset.
76 @param[in] len the length of LOB data that needs to be fetched.
77 @param[out] buf the output buffer (owned by caller) of minimum len bytes.
78 @return the amount of data (in bytes) that was actually read. */
79 ulint z_read(lob::ReadContext *ctx, lob::ref_t ref, ulint offset, ulint len,
80 byte *buf);
81
82 /** Print information about the given LOB.
83 @param[in] trx the current transaction.
84 @param[in] index the clust index that contains the LOB.
85 @param[in] out the output stream into which LOB info is printed.
86 @param[in] ref the LOB reference
87 @param[in] fatal if true assert at end of function. */
88 void print(trx_t *trx, dict_index_t *index, std::ostream &out, ref_t ref,
89 bool fatal);
90
91 /** Print information about the given compressed lob. */
92 dberr_t z_print_info(const dict_index_t *index, const lob::ref_t &ref,
93 std::ostream &out);
94
95 /** Update a portion of the given LOB.
96 @param[in] trx the transaction that is doing the modification.
97 @param[in] index the clustered index containing the LOB.
98 @param[in] upd update vector
99 @param[in] field_no the LOB field number
100 @return DB_SUCCESS on success, error code on failure. */
101 dberr_t update(trx_t *trx, dict_index_t *index, const upd_t *upd,
102 ulint field_no);
103
104 /** Update a portion of the given LOB.
105 @param[in] trx the transaction that is doing the modification.
106 @param[in] index the clustered index containing the LOB.
107 @param[in] upd update vector
108 @param[in] field_no the LOB field number
109 @return DB_SUCCESS on success, error code on failure. */
110 dberr_t z_update(trx_t *trx, dict_index_t *index, const upd_t *upd,
111 ulint field_no);
112
113 /** Get the list of index entries affected by the given partial update
114 vector.
115 @param[in] ref LOB reference object.
116 @param[in] index Clustered index to which LOB belongs.
117 @param[in] bdiff Single partial update vector
118 @param[out] entries Affected LOB index entries.
119 @param[in] mtr Mini-transaction
120 @return DB_SUCCESS on success, error code on failure. */
121 dberr_t get_affected_index_entries(const ref_t &ref, dict_index_t *index,
122 const Binary_diff &bdiff,
123 List_iem_t &entries, mtr_t *mtr);
124
125 /** Apply the undo log on the LOB
126 @param[in] mtr Mini-transaction context.
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, 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