1
/*****************************************************************************
3
Copyright (C) 1994, 2009, Innobase Oy. 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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/btr0cur.ic
23
Created 10/16/1994 Heikki Tuuri
24
*******************************************************/
26
#ifndef UNIV_HOTBACKUP
30
/*********************************************************//**
31
Returns the page cursor component of a tree cursor.
32
@return pointer to page cursor component */
37
const btr_cur_t* cursor) /*!< in: tree cursor */
39
return(&((btr_cur_t*) cursor)->page_cur);
41
#endif /* UNIV_DEBUG */
42
/*********************************************************//**
43
Returns the buffer block on which the tree cursor is positioned.
44
@return pointer to buffer block */
49
btr_cur_t* cursor) /*!< in: tree cursor */
51
return(page_cur_get_block(btr_cur_get_page_cur(cursor)));
54
/*********************************************************//**
55
Returns the record pointer of a tree cursor.
56
@return pointer to record */
61
btr_cur_t* cursor) /*!< in: tree cursor */
63
return(page_cur_get_rec(&(cursor->page_cur)));
66
/*********************************************************//**
67
Returns the compressed page on which the tree cursor is positioned.
68
@return pointer to compressed page, or NULL if the page is not compressed */
73
btr_cur_t* cursor) /*!< in: tree cursor */
75
return(buf_block_get_page_zip(btr_cur_get_block(cursor)));
78
/*********************************************************//**
79
Invalidates a tree cursor by setting record pointer to NULL. */
84
btr_cur_t* cursor) /*!< in: tree cursor */
86
page_cur_invalidate(&(cursor->page_cur));
89
/*********************************************************//**
90
Returns the page of a tree cursor.
91
@return pointer to page */
96
btr_cur_t* cursor) /*!< in: tree cursor */
98
return(page_align(page_cur_get_rec(&(cursor->page_cur))));
101
/*********************************************************//**
102
Returns the index of a cursor.
108
btr_cur_t* cursor) /*!< in: B-tree cursor */
110
return(cursor->index);
113
/*********************************************************//**
114
Positions a tree cursor at a given record. */
119
dict_index_t* index, /*!< in: index */
120
rec_t* rec, /*!< in: record in tree */
121
buf_block_t* block, /*!< in: buffer block of rec */
122
btr_cur_t* cursor) /*!< out: cursor */
124
ut_ad(page_align(rec) == block->frame);
126
page_cur_position(rec, block, btr_cur_get_page_cur(cursor));
128
cursor->index = index;
131
/*********************************************************************//**
132
Checks if compressing an index page where a btr cursor is placed makes
134
@return TRUE if compression is recommended */
137
btr_cur_compress_recommendation(
138
/*============================*/
139
btr_cur_t* cursor, /*!< in: btr cursor */
140
mtr_t* mtr) /*!< in: mtr */
144
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
145
MTR_MEMO_PAGE_X_FIX));
147
page = btr_cur_get_page(cursor);
149
if ((page_get_data_size(page) < BTR_CUR_PAGE_COMPRESS_LIMIT)
150
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
151
&& (btr_page_get_prev(page, mtr) == FIL_NULL))) {
153
/* The page fillfactor has dropped below a predefined
154
minimum value OR the level in the B-tree contains just
155
one page: we recommend compression if this is not the
158
return(dict_index_get_page(cursor->index)
159
!= page_get_page_no(page));
165
/*********************************************************************//**
166
Checks if the record on which the cursor is placed can be deleted without
167
making tree compression necessary (or, recommended).
168
@return TRUE if can be deleted without recommended compression */
171
btr_cur_can_delete_without_compress(
172
/*================================*/
173
btr_cur_t* cursor, /*!< in: btr cursor */
174
ulint rec_size,/*!< in: rec_get_size(btr_cur_get_rec(cursor))*/
175
mtr_t* mtr) /*!< in: mtr */
179
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
180
MTR_MEMO_PAGE_X_FIX));
182
page = btr_cur_get_page(cursor);
184
if ((page_get_data_size(page) - rec_size < BTR_CUR_PAGE_COMPRESS_LIMIT)
185
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
186
&& (btr_page_get_prev(page, mtr) == FIL_NULL))
187
|| (page_get_n_recs(page) < 2)) {
189
/* The page fillfactor will drop below a predefined
190
minimum value, OR the level in the B-tree contains just
191
one page, OR the page will become empty: we recommend
192
compression if this is not the root page. */
194
return(dict_index_get_page(cursor->index)
195
== page_get_page_no(page));
200
#endif /* !UNIV_HOTBACKUP */