1 /***************************************************************************** 2 3 Copyright (c) 2016, 2019, Oracle and/or its affiliates. All Rights Reserved. 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 the LOB reference object. 115 @param[in] index the 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 the mini transaction 119 @return DB_SUCCESS on success, error code on failure. */ 120 dberr_t get_affected_index_entries(const ref_t &ref, dict_index_t *index, 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 the mini transaction context. 126 @param[in] trx the transaction that is being rolled back. 127 @param[in] index the clustered index to which LOB belongs. 128 @param[in] ref the LOB reference object. 129 @param[in] uf the 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 the LOB reference. 136 @param[in] index the clustered index to which LOB belongs. 137 @param[out] lob_version the lob version number. 138 @param[out] last_trx_id the trx_id that modified the lob last. 139 @param[out] last_undo_no the trx undo no that modified the lob last. 140 @param[out] page_type the page type of first lob page. 141 @param[in] mtr the 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 the location of the first LOB index entry. 152 @param[in] mtr the 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 160