1
/******************************************************
4
(c) 1994-1996 Innobase Oy
6
Created 10/16/1994 Heikki Tuuri
7
*******************************************************/
12
/*************************************************************
13
Returns the page cursor component of a tree cursor. */
18
/* out: pointer to page cursor
20
const btr_cur_t* cursor) /* in: tree cursor */
22
return(&((btr_cur_t*) cursor)->page_cur);
24
#endif /* UNIV_DEBUG */
25
/*************************************************************
26
Returns the buffer block on which the tree cursor is positioned. */
31
/* out: pointer to buffer block */
32
btr_cur_t* cursor) /* in: tree cursor */
34
return(page_cur_get_block(btr_cur_get_page_cur(cursor)));
37
/*************************************************************
38
Returns the record pointer of a tree cursor. */
43
/* out: pointer to record */
44
btr_cur_t* cursor) /* in: tree cursor */
46
return(page_cur_get_rec(&(cursor->page_cur)));
49
/*************************************************************
50
Returns the compressed page on which the tree cursor is positioned. */
55
/* out: pointer to compressed page,
56
or NULL if the page is not compressed */
57
btr_cur_t* cursor) /* in: tree cursor */
59
return(buf_block_get_page_zip(btr_cur_get_block(cursor)));
62
/*************************************************************
63
Invalidates a tree cursor by setting record pointer to NULL. */
68
btr_cur_t* cursor) /* in: tree cursor */
70
page_cur_invalidate(&(cursor->page_cur));
73
/*************************************************************
74
Returns the page of a tree cursor. */
79
/* out: pointer to page */
80
btr_cur_t* cursor) /* in: tree cursor */
82
return(page_align(page_cur_get_rec(&(cursor->page_cur))));
85
/*************************************************************
86
Returns the index of a cursor. */
92
btr_cur_t* cursor) /* in: B-tree cursor */
94
return(cursor->index);
97
/*************************************************************
98
Positions a tree cursor at a given record. */
103
dict_index_t* index, /* in: index */
104
rec_t* rec, /* in: record in tree */
105
buf_block_t* block, /* in: buffer block of rec */
106
btr_cur_t* cursor) /* out: cursor */
108
ut_ad(page_align(rec) == block->frame);
110
page_cur_position(rec, block, btr_cur_get_page_cur(cursor));
112
cursor->index = index;
115
/*************************************************************************
116
Checks if compressing an index page where a btr cursor is placed makes
120
btr_cur_compress_recommendation(
121
/*============================*/
122
/* out: TRUE if compression is recommended */
123
btr_cur_t* cursor, /* in: btr cursor */
124
mtr_t* mtr) /* in: mtr */
128
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
129
MTR_MEMO_PAGE_X_FIX));
131
page = btr_cur_get_page(cursor);
133
if ((page_get_data_size(page) < BTR_CUR_PAGE_COMPRESS_LIMIT)
134
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
135
&& (btr_page_get_prev(page, mtr) == FIL_NULL))) {
137
/* The page fillfactor has dropped below a predefined
138
minimum value OR the level in the B-tree contains just
139
one page: we recommend compression if this is not the
142
return(dict_index_get_page(cursor->index)
143
!= page_get_page_no(page));
149
/*************************************************************************
150
Checks if the record on which the cursor is placed can be deleted without
151
making tree compression necessary (or, recommended). */
154
btr_cur_can_delete_without_compress(
155
/*================================*/
156
/* out: TRUE if can be deleted without
157
recommended compression */
158
btr_cur_t* cursor, /* in: btr cursor */
159
ulint rec_size,/* in: rec_get_size(btr_cur_get_rec(cursor))*/
160
mtr_t* mtr) /* in: mtr */
164
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
165
MTR_MEMO_PAGE_X_FIX));
167
page = btr_cur_get_page(cursor);
169
if ((page_get_data_size(page) - rec_size < BTR_CUR_PAGE_COMPRESS_LIMIT)
170
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
171
&& (btr_page_get_prev(page, mtr) == FIL_NULL))
172
|| (page_get_n_recs(page) < 2)) {
174
/* The page fillfactor will drop below a predefined
175
minimum value, OR the level in the B-tree contains just
176
one page, OR the page will become empty: we recommend
177
compression if this is not the root page. */
179
return(dict_index_get_page(cursor->index)
180
== page_get_page_no(page));