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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/********************************************************************//**
20
@file include/btr0types.h
21
The index tree general types
23
Created 2/17/1996 Heikki Tuuri
24
*************************************************************************/
31
#include "rem0types.h"
32
#include "page0types.h"
35
/** Persistent cursor */
36
typedef struct btr_pcur_struct btr_pcur_t;
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
#ifndef UNIV_HOTBACKUP
44
/** @brief The latch protecting the adaptive search system
46
This latch protects the
48
(2) columns of a record to which we have a pointer in the hash index;
52
(3) next record offset field in a record;
53
(4) next or previous records on the same page.
55
Bear in mind (3) and (4) when using the hash index.
57
extern rw_lock_t* btr_search_latch_temp;
59
#endif /* UNIV_HOTBACKUP */
61
/** The latch protecting the adaptive search system */
62
#define btr_search_latch (*btr_search_latch_temp)
64
/** Flag: has the search system been enabled?
65
Protected by btr_search_latch. */
66
extern char btr_search_enabled;
68
#ifdef UNIV_BLOB_DEBUG
69
# include "buf0types.h"
70
/** An index->blobs entry for keeping track of off-page column references */
71
typedef struct btr_blob_dbg_struct btr_blob_dbg_t;
73
/** Insert to index->blobs a reference to an off-page column.
74
@param index the index tree
75
@param b the reference
76
@param ctx context (for logging) */
79
btr_blob_dbg_rbt_insert(
80
/*====================*/
81
dict_index_t* index, /*!< in/out: index tree */
82
const btr_blob_dbg_t* b, /*!< in: the reference */
83
const char* ctx) /*!< in: context (for logging) */
84
__attribute__((nonnull));
86
/** Remove from index->blobs a reference to an off-page column.
87
@param index the index tree
88
@param b the reference
89
@param ctx context (for logging) */
92
btr_blob_dbg_rbt_delete(
93
/*====================*/
94
dict_index_t* index, /*!< in/out: index tree */
95
const btr_blob_dbg_t* b, /*!< in: the reference */
96
const char* ctx) /*!< in: context (for logging) */
97
__attribute__((nonnull));
99
/**************************************************************//**
100
Add to index->blobs any references to off-page columns from a record.
101
@return number of references added */
104
btr_blob_dbg_add_rec(
105
/*=================*/
106
const rec_t* rec, /*!< in: record */
107
dict_index_t* index, /*!< in/out: index */
108
const ulint* offsets,/*!< in: offsets */
109
const char* ctx) /*!< in: context (for logging) */
110
__attribute__((nonnull));
111
/**************************************************************//**
112
Remove from index->blobs any references to off-page columns from a record.
113
@return number of references removed */
116
btr_blob_dbg_remove_rec(
117
/*====================*/
118
const rec_t* rec, /*!< in: record */
119
dict_index_t* index, /*!< in/out: index */
120
const ulint* offsets,/*!< in: offsets */
121
const char* ctx) /*!< in: context (for logging) */
122
__attribute__((nonnull));
123
/**************************************************************//**
124
Count and add to index->blobs any references to off-page columns
125
from records on a page.
126
@return number of references added */
131
const page_t* page, /*!< in: rewritten page */
132
dict_index_t* index, /*!< in/out: index */
133
const char* ctx) /*!< in: context (for logging) */
134
__attribute__((nonnull));
135
/**************************************************************//**
136
Count and remove from index->blobs any references to off-page columns
137
from records on a page.
138
Used when reorganizing a page, before copying the records.
139
@return number of references removed */
144
const page_t* page, /*!< in: b-tree page */
145
dict_index_t* index, /*!< in/out: index */
146
const char* ctx) /*!< in: context (for logging) */
147
__attribute__((nonnull));
148
/**************************************************************//**
149
Restore in index->blobs any references to off-page columns
150
Used when page reorganize fails due to compressed page overflow. */
153
btr_blob_dbg_restore(
154
/*=================*/
155
const page_t* npage, /*!< in: page that failed to compress */
156
const page_t* page, /*!< in: copy of original page */
157
dict_index_t* index, /*!< in/out: index */
158
const char* ctx) /*!< in: context (for logging) */
159
__attribute__((nonnull));
161
/** Operation that processes the BLOB references of an index record
162
@param[in] rec record on index page
163
@param[in/out] index the index tree of the record
164
@param[in] offsets rec_get_offsets(rec,index)
165
@param[in] ctx context (for logging)
166
@return number of BLOB references processed */
167
typedef ulint (*btr_blob_dbg_op_f)
168
(const rec_t* rec,dict_index_t* index,const ulint* offsets,const char* ctx);
170
/**************************************************************//**
171
Count and process all references to off-page columns on a page.
172
@return number of references processed */
177
const page_t* page, /*!< in: B-tree leaf page */
178
const rec_t* rec, /*!< in: record to start from
179
(NULL to process the whole page) */
180
dict_index_t* index, /*!< in/out: index */
181
const char* ctx, /*!< in: context (for logging) */
182
const btr_blob_dbg_op_f op) /*!< in: operation on records */
183
__attribute__((nonnull(1,3,4,5)));
184
#else /* UNIV_BLOB_DEBUG */
185
# define btr_blob_dbg_add_rec(rec, index, offsets, ctx) ((void) 0)
186
# define btr_blob_dbg_add(page, index, ctx) ((void) 0)
187
# define btr_blob_dbg_remove_rec(rec, index, offsets, ctx) ((void) 0)
188
# define btr_blob_dbg_remove(page, index, ctx) ((void) 0)
189
# define btr_blob_dbg_restore(npage, page, index, ctx) ((void) 0)
190
# define btr_blob_dbg_op(page, rec, index, ctx, op) ((void) 0)
191
#endif /* UNIV_BLOB_DEBUG */
193
/** The size of a reference to data stored on a different page.
194
The reference is stored at the end of the prefix of the field
195
in the index record. */
196
#define BTR_EXTERN_FIELD_REF_SIZE 20
198
/** A BLOB field reference full of zero, for use in assertions and tests.
199
Initially, BLOB field references are set to zero, in
200
dtuple_convert_big_rec(). */
201
extern const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE];