1 /*****************************************************************************
2 
3 Copyright (c) 2006, 2009, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8 
9 This program is also distributed 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 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License, version 2.0, 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 Street, Suite 500, Boston, MA 02110-1335 USA
24 
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 "univ.i"
38 #include "row0types.h"
39 #include "data0types.h"
40 #include "mem0mem.h"
41 #include "dict0types.h"
42 
43 /********************************************************************//**
44 Creates a cache of column prefixes of externally stored columns.
45 @return	own: column prefix cache */
46 UNIV_INTERN
47 row_ext_t*
48 row_ext_create(
49 /*===========*/
50 	ulint		n_ext,	/*!< in: number of externally stored columns */
51 	const ulint*	ext,	/*!< in: col_no's of externally stored columns
52 				in the InnoDB table object, as reported by
53 				dict_col_get_no(); NOT relative to the records
54 				in the clustered index */
55 	ulint		flags, /*!< in: table->flags */
56 	const dtuple_t*	tuple,	/*!< in: data tuple containing the field
57 				references of the externally stored
58 				columns; must be indexed by col_no;
59 				the clustered index record must be
60 				covered by a lock or a page latch
61 				to prevent deletion (rollback or purge). */
62 	mem_heap_t*	heap);	/*!< in: heap where created */
63 
64 /********************************************************************//**
65 Looks up a column prefix of an externally stored column.
66 @return column prefix, or NULL if the column is not stored externally,
67 or pointer to field_ref_zero if the BLOB pointer is unset */
68 UNIV_INLINE
69 const byte*
70 row_ext_lookup_ith(
71 /*===============*/
72 	const row_ext_t*	ext,	/*!< in/out: column prefix cache */
73 	ulint			i,	/*!< in: index of ext->ext[] */
74 	ulint*			len);	/*!< out: length of prefix, in bytes,
75 					at most the length determined by
76 					DICT_MAX_FIELD_LEN_BY_FORMAT() */
77 /********************************************************************//**
78 Looks up a column prefix of an externally stored column.
79 @return column prefix, or NULL if the column is not stored externally,
80 or pointer to field_ref_zero if the BLOB pointer is unset */
81 UNIV_INLINE
82 const byte*
83 row_ext_lookup(
84 /*===========*/
85 	const row_ext_t*	ext,	/*!< in: column prefix cache */
86 	ulint			col,	/*!< in: column number in the InnoDB
87 					table object, as reported by
88 					dict_col_get_no(); NOT relative to the
89 					records in the clustered index */
90 	ulint*			len);	/*!< out: length of prefix, in bytes,
91 					at most the length determined by
92 					DICT_MAX_FIELD_LEN_BY_FORMAT() */
93 
94 /** Prefixes of externally stored columns */
95 struct row_ext_t{
96 	ulint		n_ext;	/*!< number of externally stored columns */
97 	const ulint*	ext;	/*!< col_no's of externally stored columns */
98 	byte*		buf;	/*!< backing store of the column prefix cache */
99 	ulint		max_len;/*!< maximum prefix length, it could be
100 				REC_ANTELOPE_MAX_INDEX_COL_LEN or
101 				REC_VERSION_56_MAX_INDEX_COL_LEN depending
102 				on row format */
103 	ulint		len[1];	/*!< prefix lengths; 0 if not cached */
104 };
105 
106 #ifndef UNIV_NONINL
107 #include "row0ext.ic"
108 #endif
109 
110 #endif
111