MySQL  8.0.19
Source Code Documentation
row0ext.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2006, 2018, 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 
27 /** @file include/row0ext.h
28  Caching of externally stored column prefixes
29 
30  Created September 2006 Marko Makela
31  *******************************************************/
32 
33 #ifndef row0ext_h
34 #define row0ext_h
35 
36 #include "data0types.h"
37 #include "dict0types.h"
38 #include "mem0mem.h"
39 #include "page0size.h"
40 #include "row0types.h"
41 #include "univ.i"
42 
43 #ifdef UNIV_DEBUG
44 #define row_ext_create(index, n_ext, ext, flags, tuple, is_sdi, heap) \
45  row_ext_create_func(index, n_ext, ext, flags, tuple, is_sdi, heap)
46 #else /* UNIV_DEBUG */
47 #define row_ext_create(index, n_ext, ext, flags, tuple, is_sdi, heap) \
48  row_ext_create_func(index, n_ext, ext, flags, tuple, heap)
49 #endif /* UNIV_DEBUG */
50 
51 /** Creates a cache of column prefixes of externally stored columns.
52 @param[in] index the index to which LOB belongs.
53 @param[in] n_ext number of externally stored columns
54 @param[in] ext col_no's of externally stored columns in the InnoDB
55 table object, as reported by dict_col_get_no(); NOT relative to the records
56 in the clustered index
57 @param[in] flags table->flags
58 @param[in] tuple data tuple containing the field references of the
59 externally stored columns; must be indexed by col_no; the clustered index record
60 must be covered by a lock or a page latch to prevent deletion (rollback
61 or purge)
62 @param[in] is_sdi true for SDI Indexes
63 @param[in] heap heap where created
64 @return own: column prefix cache */
65 row_ext_t *row_ext_create_func(const dict_index_t *index, ulint n_ext,
66  const ulint *ext, ulint flags,
67  const dtuple_t *tuple,
68 #ifdef UNIV_DEBUG
69  bool is_sdi,
70 #endif /* UNIV_DEBUG */
71  mem_heap_t *heap);
72 
73 /** Looks up a column prefix of an externally stored column.
74 @param[in,out] ext column prefix cache
75 @param[in] i index of ext->ext[]
76 @param[out] len length of prefix, in bytes, at most the length
77  determined by DICT_MAX_FIELD_LEN_BY_FORMAT()
78 @return column prefix, or NULL if the column is not stored externally,
79 or pointer to field_ref_zero if the BLOB pointer is unset */
80 UNIV_INLINE
81 const byte *row_ext_lookup_ith(const row_ext_t *ext, ulint i, ulint *len);
82 
83 /** Looks up a column prefix of an externally stored column.
84 @param[in] ext column prefix cache
85 @param[in] col column number in the InnoDB table object, as reported
86  by dict_col_get_no(); NOT relative to the records in
87  the clustered index
88 @param[out] len length of prefix, in bytes, at most the length
89  determined by DICT_MAX_FIELD_LEN_BY_FORMAT()
90 @return column prefix, or NULL if the column is not stored externally,
91 or pointer to field_ref_zero if the BLOB pointer is unset */
92 UNIV_INLINE
93 const byte *row_ext_lookup(const row_ext_t *ext, ulint col, ulint *len);
94 
95 /** Prefixes of externally stored columns */
96 struct row_ext_t {
97  /** The clustered index from where LOB is fetched. */
99 
100  ulint n_ext; /*!< number of externally stored columns */
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 */
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
dtuple_t
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:716
mem0mem.h
dict0types.h
ut_print_buf
void ut_print_buf(FILE *file, const void *buf, ulint len)
NOTE: The functions in this file should only use functions from other files in library.
Definition: ut.cc:46
dict_index_t
Data structure for an index.
Definition: dict0mem.h:869
row_ext_t
Prefixes of externally stored columns.
Definition: row0ext.h:96
row_ext_t::n_ext
ulint n_ext
number of externally stored columns
Definition: row0ext.h:100
row_ext_t::ext
const ulint * ext
col_no's of externally stored columns
Definition: row0ext.h:101
row_ext_lookup_ith
const UNIV_INLINE byte * row_ext_lookup_ith(const row_ext_t *ext, ulint i, ulint *len)
Looks up a column prefix of an externally stored column.
row_ext_t::max_len
ulint max_len
maximum prefix length, it could be REC_ANTELOPE_MAX_INDEX_COL_LEN or REC_VERSION_56_MAX_INDEX_COL_LEN...
Definition: row0ext.h:103
row_ext_t::buf
byte * buf
backing store of the column prefix cache
Definition: row0ext.h:102
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
row_ext_t::index
const dict_index_t * index
The clustered index from where LOB is fetched.
Definition: row0ext.h:98
row_ext_t::len
ulint len[1]
prefix lengths; 0 if not cached
Definition: row0ext.h:110
page_size_t
Page size descriptor.
Definition: page0size.h:50
page0size.h
row0types.h
row_ext_lookup
const UNIV_INLINE byte * row_ext_lookup(const row_ext_t *ext, ulint col, ulint *len)
Looks up a column prefix of an externally stored column.
row_ext_create_func
row_ext_t * row_ext_create_func(const dict_index_t *index, ulint n_ext, const ulint *ext, ulint flags, const dtuple_t *tuple, bool is_sdi, mem_heap_t *heap)
Creates a cache of column prefixes of externally stored columns.
Definition: row0ext.cc:117
data0types.h
row_ext_t::print
std::ostream & print(std::ostream &out) const
Definition: row0ext.h:114
operator<<
std::ostream & operator<<(std::ostream &out, const row_ext_t &obj)
Definition: row0ext.h:127
index
char * index(const char *, int c)
Definition: mysql.cc:2875
row_ext_t::page_size
page_size_t page_size
page size of the externally stored columns
Definition: row0ext.h:107
flags
static int flags[50]
Definition: hp_test1.cc:39