| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2006, 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 |
|
| 28 |
/** @file include/row0ext.h |
| 29 |
Caching of externally stored column prefixes |
| 30 |
|
| 31 |
Created September 2006 Marko Makela |
| 32 |
*******************************************************/ |
| 33 |
|
| 34 |
#ifndef row0ext_h |
| 35 |
#define row0ext_h |
| 36 |
|
| 37 |
#include "data0types.h" |
| 38 |
#include "dict0types.h" |
| 39 |
#include "mem0mem.h" |
| 40 |
#include "page0size.h" |
| 41 |
#include "row0types.h" |
| 42 |
#include "univ.i" |
| 43 |
|
| 44 |
/** Creates a cache of column prefixes of externally stored columns. |
| 45 |
@param[in] index the index to which LOB belongs. |
| 46 |
@param[in] n_ext number of externally stored columns |
| 47 |
@param[in] ext col_no's of externally stored columns in the InnoDB |
| 48 |
table object, as reported by dict_col_get_no(); NOT relative to the records |
| 49 |
in the clustered index |
| 50 |
@param[in] flags table->flags |
| 51 |
@param[in] tuple data tuple containing the field references of the |
| 52 |
externally stored columns; must be indexed by col_no; the clustered index record |
| 53 |
must be covered by a lock or a page latch to prevent deletion (rollback |
| 54 |
or purge) |
| 55 |
@param[in] is_sdi true for SDI Indexes |
| 56 |
@param[in,out] heap heap where created |
| 57 |
@return own: column prefix cache */ |
| 58 |
row_ext_t *row_ext_create_func(const dict_index_t *index, ulint n_ext, |
| 59 |
const ulint *ext, uint32_t flags, |
| 60 |
const dtuple_t *tuple, |
| 61 |
IF_DEBUG(bool is_sdi, ) mem_heap_t *heap); |
| 62 |
|
| 63 |
static inline row_ext_t *row_ext_create(const dict_index_t *index, ulint n_ext, |
| 64 |
const ulint *ext, uint32_t flags, |
| 65 |
const dtuple_t *tuple, |
| 66 |
bool is_sdi [[maybe_unused]], |
| 67 |
mem_heap_t *heap) { |
| 68 |
return row_ext_create_func(index, n_ext, ext, flags, tuple, |
| 69 |
IF_DEBUG(is_sdi, ) heap); |
| 70 |
} |
| 71 |
|
| 72 |
/** Looks up a column prefix of an externally stored column. |
| 73 |
@param[in,out] ext column prefix cache |
| 74 |
@param[in] i index of ext->ext[] |
| 75 |
@param[out] len length of prefix, in bytes, at most the length |
| 76 |
determined by DICT_MAX_FIELD_LEN_BY_FORMAT() |
| 77 |
@return column prefix, or NULL if the column is not stored externally, |
| 78 |
or pointer to field_ref_zero if the BLOB pointer is unset */ |
| 79 |
static inline const byte *row_ext_lookup_ith(const row_ext_t *ext, ulint i, |
| 80 |
ulint *len); |
| 81 |
|
| 82 |
/** Looks up a column prefix of an externally stored column. |
| 83 |
@param[in] ext column prefix cache |
| 84 |
@param[in] col column number in the InnoDB table object, as reported |
| 85 |
by dict_col_get_no(); NOT relative to the records in |
| 86 |
the clustered index |
| 87 |
@param[out] len length of prefix, in bytes, at most the length |
| 88 |
determined by DICT_MAX_FIELD_LEN_BY_FORMAT() |
| 89 |
@return column prefix, or NULL if the column is not stored externally, |
| 90 |
or pointer to field_ref_zero if the BLOB pointer is unset */ |
| 91 |
static inline const byte *row_ext_lookup(const row_ext_t *ext, ulint col, |
| 92 |
ulint *len); |
| 93 |
|
| 94 |
/** Prefixes of externally stored columns */ |
| 95 |
struct row_ext_t { |
| 96 |
/** The clustered index from where LOB is fetched. */ |
| 97 |
const dict_index_t *index; |
| 98 |
|
| 99 |
ulint n_ext; /*!< number of externally stored columns which are part of |
| 100 |
index */ |
| 101 |
const ulint *ext; /*!< col_no's of externally stored columns */ |
| 102 |
byte *buf; /*!< backing store of the column prefix cache */ |
| 103 |
ulint max_len; /*!< maximum prefix length, it could be |
| 104 |
REC_ANTELOPE_MAX_INDEX_COL_LEN or |
| 105 |
REC_VERSION_56_MAX_INDEX_COL_LEN depending |
| 106 |
on row format */ |
| 107 |
page_size_t page_size; |
| 108 |
/*!< page size of the externally stored |
| 109 |
columns */ |
| 110 |
ulint len[1]; /*!< prefix lengths; 0 if not cached */ |
| 111 |
|
| 112 |
/* NOTE: Do NOT add new members here. */ |
| 113 |
|
| 114 |
std::ostream &print(std::ostream &out) const { |
| 115 |
out << "[row_ext_t:"; |
| 116 |
for (ulint i = 0; i < n_ext; i++) { |
| 117 |
if (len[i] > 0) { |
| 118 |
byte *ptr = (buf + i * max_len); |
| 119 |
ut_print_buf(out, ptr, len[i]); |
| 120 |
} |
| 121 |
} |
| 122 |
out << "]" << std::endl; |
| 123 |
return (out); |
| 124 |
} |
| 125 |
}; |
| 126 |
|
| 127 |
inline std::ostream &operator<<(std::ostream &out, const row_ext_t &obj) { |
| 128 |
return (obj.print(out)); |
| 129 |
} |
| 130 |
|
| 131 |
#include "row0ext.ic" |
| 132 |
|
| 133 |
#endif |