mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / btr0types.h
blobe572e1cb2f4786675b3faee295e80184ffb0a128
1 /*****************************************************************************
3 Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
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.
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.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /********************************************************************//**
20 @file include/btr0types.h
21 The index tree general types
23 Created 2/17/1996 Heikki Tuuri
24 *************************************************************************/
26 #ifndef btr0types_h
27 #define btr0types_h
29 #include "univ.i"
31 #include "rem0types.h"
32 #include "page0types.h"
33 #include "sync0rw.h"
35 /** Persistent cursor */
36 typedef struct btr_pcur_struct btr_pcur_t;
37 /** B-tree cursor */
38 typedef struct btr_cur_struct btr_cur_t;
39 /** B-tree search information for the adaptive hash index */
40 typedef struct btr_search_struct btr_search_t;
42 /** @brief The latch protecting the adaptive search system
44 This latch protects the
45 (1) hash index;
46 (2) columns of a record to which we have a pointer in the hash index;
48 but does NOT protect:
50 (3) next record offset field in a record;
51 (4) next or previous records on the same page.
53 Bear in mind (3) and (4) when using the hash index.
55 extern rw_lock_t* btr_search_latch_temp;
57 /** The latch protecting the adaptive search system */
58 #define btr_search_latch (*btr_search_latch_temp)
60 /** Flag: has the search system been enabled?
61 Protected by btr_search_latch. */
62 extern char btr_search_enabled;
64 #ifdef UNIV_BLOB_DEBUG
65 # include "buf0types.h"
66 /** An index->blobs entry for keeping track of off-page column references */
67 typedef struct btr_blob_dbg_struct btr_blob_dbg_t;
69 /** Insert to index->blobs a reference to an off-page column.
70 @param index the index tree
71 @param b the reference
72 @param ctx context (for logging) */
73 UNIV_INTERN
74 void
75 btr_blob_dbg_rbt_insert(
76 /*====================*/
77 dict_index_t* index, /*!< in/out: index tree */
78 const btr_blob_dbg_t* b, /*!< in: the reference */
79 const char* ctx) /*!< in: context (for logging) */
80 __attribute__((nonnull));
82 /** Remove from index->blobs a reference to an off-page column.
83 @param index the index tree
84 @param b the reference
85 @param ctx context (for logging) */
86 UNIV_INTERN
87 void
88 btr_blob_dbg_rbt_delete(
89 /*====================*/
90 dict_index_t* index, /*!< in/out: index tree */
91 const btr_blob_dbg_t* b, /*!< in: the reference */
92 const char* ctx) /*!< in: context (for logging) */
93 __attribute__((nonnull));
95 /**************************************************************//**
96 Add to index->blobs any references to off-page columns from a record.
97 @return number of references added */
98 UNIV_INTERN
99 ulint
100 btr_blob_dbg_add_rec(
101 /*=================*/
102 const rec_t* rec, /*!< in: record */
103 dict_index_t* index, /*!< in/out: index */
104 const ulint* offsets,/*!< in: offsets */
105 const char* ctx) /*!< in: context (for logging) */
106 __attribute__((nonnull));
107 /**************************************************************//**
108 Remove from index->blobs any references to off-page columns from a record.
109 @return number of references removed */
110 UNIV_INTERN
111 ulint
112 btr_blob_dbg_remove_rec(
113 /*====================*/
114 const rec_t* rec, /*!< in: record */
115 dict_index_t* index, /*!< in/out: index */
116 const ulint* offsets,/*!< in: offsets */
117 const char* ctx) /*!< in: context (for logging) */
118 __attribute__((nonnull));
119 /**************************************************************//**
120 Count and add to index->blobs any references to off-page columns
121 from records on a page.
122 @return number of references added */
123 UNIV_INTERN
124 ulint
125 btr_blob_dbg_add(
126 /*=============*/
127 const page_t* page, /*!< in: rewritten page */
128 dict_index_t* index, /*!< in/out: index */
129 const char* ctx) /*!< in: context (for logging) */
130 __attribute__((nonnull));
131 /**************************************************************//**
132 Count and remove from index->blobs any references to off-page columns
133 from records on a page.
134 Used when reorganizing a page, before copying the records.
135 @return number of references removed */
136 UNIV_INTERN
137 ulint
138 btr_blob_dbg_remove(
139 /*================*/
140 const page_t* page, /*!< in: b-tree page */
141 dict_index_t* index, /*!< in/out: index */
142 const char* ctx) /*!< in: context (for logging) */
143 __attribute__((nonnull));
144 /**************************************************************//**
145 Restore in index->blobs any references to off-page columns
146 Used when page reorganize fails due to compressed page overflow. */
147 UNIV_INTERN
148 void
149 btr_blob_dbg_restore(
150 /*=================*/
151 const page_t* npage, /*!< in: page that failed to compress */
152 const page_t* page, /*!< in: copy of original page */
153 dict_index_t* index, /*!< in/out: index */
154 const char* ctx) /*!< in: context (for logging) */
155 __attribute__((nonnull));
157 /** Operation that processes the BLOB references of an index record
158 @param[in] rec record on index page
159 @param[in/out] index the index tree of the record
160 @param[in] offsets rec_get_offsets(rec,index)
161 @param[in] ctx context (for logging)
162 @return number of BLOB references processed */
163 typedef ulint (*btr_blob_dbg_op_f)
164 (const rec_t* rec,dict_index_t* index,const ulint* offsets,const char* ctx);
166 /**************************************************************//**
167 Count and process all references to off-page columns on a page.
168 @return number of references processed */
169 UNIV_INTERN
170 ulint
171 btr_blob_dbg_op(
172 /*============*/
173 const page_t* page, /*!< in: B-tree leaf page */
174 const rec_t* rec, /*!< in: record to start from
175 (NULL to process the whole page) */
176 dict_index_t* index, /*!< in/out: index */
177 const char* ctx, /*!< in: context (for logging) */
178 const btr_blob_dbg_op_f op) /*!< in: operation on records */
179 __attribute__((nonnull(1,3,4,5)));
180 #else /* UNIV_BLOB_DEBUG */
181 # define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0)
182 # define btr_blob_dbg_add(page, index, ctx) ((void) 0)
183 # define btr_blob_dbg_remove_rec(rec, index, offsets, ctx) ((void) 0)
184 # define btr_blob_dbg_remove(page, index, ctx) ((void) 0)
185 # define btr_blob_dbg_restore(npage, page, index, ctx) ((void) 0)
186 # define btr_blob_dbg_op(page, rec, index, ctx, op) ((void) 0)
187 #endif /* UNIV_BLOB_DEBUG */
189 /** The size of a reference to data stored on a different page.
190 The reference is stored at the end of the prefix of the field
191 in the index record. */
192 #define BTR_EXTERN_FIELD_REF_SIZE 20
194 /** A BLOB field reference full of zero, for use in assertions and tests.
195 Initially, BLOB field references are set to zero, in
196 dtuple_convert_big_rec(). */
197 extern const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE];
199 #endif