| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2006, 2016, 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 as published by the Free Software |
| 7 | Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along with |
| 14 | this program; if not, write to the Free Software Foundation, Inc., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/row0ext.h |
| 21 | Caching of externally stored column prefixes |
| 22 | |
| 23 | Created September 2006 Marko Makela |
| 24 | *******************************************************/ |
| 25 | |
| 26 | #ifndef row0ext_h |
| 27 | #define row0ext_h |
| 28 | |
| 29 | #include "univ.i" |
| 30 | #include "row0types.h" |
| 31 | #include "data0types.h" |
| 32 | #include "mem0mem.h" |
| 33 | #include "dict0types.h" |
| 34 | #include "page0size.h" |
| 35 | |
| 36 | /********************************************************************//** |
| 37 | Creates a cache of column prefixes of externally stored columns. |
| 38 | @return own: column prefix cache */ |
| 39 | row_ext_t* |
| 40 | row_ext_create( |
| 41 | /*===========*/ |
| 42 | ulint n_ext, /*!< in: number of externally stored columns */ |
| 43 | const ulint* ext, /*!< in: col_no's of externally stored columns |
| 44 | in the InnoDB table object, as reported by |
| 45 | dict_col_get_no(); NOT relative to the records |
| 46 | in the clustered index */ |
| 47 | ulint flags, /*!< in: table->flags */ |
| 48 | const dtuple_t* tuple, /*!< in: data tuple containing the field |
| 49 | references of the externally stored |
| 50 | columns; must be indexed by col_no; |
| 51 | the clustered index record must be |
| 52 | covered by a lock or a page latch |
| 53 | to prevent deletion (rollback or purge). */ |
| 54 | mem_heap_t* heap); /*!< in: heap where created */ |
| 55 | |
| 56 | /********************************************************************//** |
| 57 | Looks up a column prefix of an externally stored column. |
| 58 | @return column prefix, or NULL if the column is not stored externally, |
| 59 | or pointer to field_ref_zero if the BLOB pointer is unset */ |
| 60 | UNIV_INLINE |
| 61 | const byte* |
| 62 | row_ext_lookup_ith( |
| 63 | /*===============*/ |
| 64 | const row_ext_t* ext, /*!< in/out: column prefix cache */ |
| 65 | ulint i, /*!< in: index of ext->ext[] */ |
| 66 | ulint* len); /*!< out: length of prefix, in bytes, |
| 67 | at most the length determined by |
| 68 | DICT_MAX_FIELD_LEN_BY_FORMAT() */ |
| 69 | /********************************************************************//** |
| 70 | Looks up a column prefix of an externally stored column. |
| 71 | @return column prefix, or NULL if the column is not stored externally, |
| 72 | or pointer to field_ref_zero if the BLOB pointer is unset */ |
| 73 | UNIV_INLINE |
| 74 | const byte* |
| 75 | row_ext_lookup( |
| 76 | /*===========*/ |
| 77 | const row_ext_t* ext, /*!< in: column prefix cache */ |
| 78 | ulint col, /*!< in: column number in the InnoDB |
| 79 | table object, as reported by |
| 80 | dict_col_get_no(); NOT relative to the |
| 81 | records in the clustered index */ |
| 82 | ulint* len); /*!< out: length of prefix, in bytes, |
| 83 | at most the length determined by |
| 84 | DICT_MAX_FIELD_LEN_BY_FORMAT() */ |
| 85 | |
| 86 | /** Prefixes of externally stored columns */ |
| 87 | struct row_ext_t{ |
| 88 | ulint n_ext; /*!< number of externally stored columns */ |
| 89 | const ulint* ext; /*!< col_no's of externally stored columns */ |
| 90 | byte* buf; /*!< backing store of the column prefix cache */ |
| 91 | ulint max_len;/*!< maximum prefix length, it could be |
| 92 | REC_ANTELOPE_MAX_INDEX_COL_LEN or |
| 93 | REC_VERSION_56_MAX_INDEX_COL_LEN depending |
| 94 | on row format */ |
| 95 | page_size_t page_size; |
| 96 | /*!< page size of the externally stored |
| 97 | columns */ |
| 98 | ulint len[1]; /*!< prefix lengths; 0 if not cached */ |
| 99 | }; |
| 100 | |
| 101 | #include "row0ext.ic" |
| 102 | |
| 103 | #endif |
| 104 | |