1
/******************************************************
4
(c) 1994-1996 Innobase Oy
6
Created 10/16/1994 Heikki Tuuri
7
*******************************************************/
11
/*************************************************************
12
Returns the page cursor component of a tree cursor. */
17
/* out: pointer to page cursor component */
18
btr_cur_t* cursor) /* in: tree cursor */
20
return(&(cursor->page_cur));
23
/*************************************************************
24
Returns the record pointer of a tree cursor. */
29
/* out: pointer to record */
30
btr_cur_t* cursor) /* in: tree cursor */
32
return(page_cur_get_rec(&(cursor->page_cur)));
35
/*************************************************************
36
Invalidates a tree cursor by setting record pointer to NULL. */
41
btr_cur_t* cursor) /* in: tree cursor */
43
page_cur_invalidate(&(cursor->page_cur));
46
/*************************************************************
47
Returns the page of a tree cursor. */
52
/* out: pointer to page */
53
btr_cur_t* cursor) /* in: tree cursor */
55
return(buf_frame_align(page_cur_get_rec(&(cursor->page_cur))));
58
/*************************************************************
59
Returns the index of a cursor. */
65
btr_cur_t* cursor) /* in: B-tree cursor */
67
return(cursor->index);
70
/*************************************************************
71
Positions a tree cursor at a given record. */
76
dict_index_t* index, /* in: index */
77
rec_t* rec, /* in: record in tree */
78
btr_cur_t* cursor) /* in: cursor */
80
page_cur_position(rec, btr_cur_get_page_cur(cursor));
82
cursor->index = index;
85
/*************************************************************************
86
Checks if compressing an index page where a btr cursor is placed makes
90
btr_cur_compress_recommendation(
91
/*============================*/
92
/* out: TRUE if compression is recommended */
93
btr_cur_t* cursor, /* in: btr cursor */
94
mtr_t* mtr) /* in: mtr */
98
ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
99
MTR_MEMO_PAGE_X_FIX));
101
page = btr_cur_get_page(cursor);
103
if ((page_get_data_size(page) < BTR_CUR_PAGE_COMPRESS_LIMIT)
104
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
105
&& (btr_page_get_prev(page, mtr) == FIL_NULL))) {
107
/* The page fillfactor has dropped below a predefined
108
minimum value OR the level in the B-tree contains just
109
one page: we recommend compression if this is not the
112
return(dict_index_get_page(cursor->index)
113
!= buf_frame_get_page_no(page));
119
/*************************************************************************
120
Checks if the record on which the cursor is placed can be deleted without
121
making tree compression necessary (or, recommended). */
124
btr_cur_can_delete_without_compress(
125
/*================================*/
126
/* out: TRUE if can be deleted without
127
recommended compression */
128
btr_cur_t* cursor, /* in: btr cursor */
129
ulint rec_size,/* in: rec_get_size(btr_cur_get_rec(cursor))*/
130
mtr_t* mtr) /* in: mtr */
134
ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
135
MTR_MEMO_PAGE_X_FIX));
137
page = btr_cur_get_page(cursor);
139
if ((page_get_data_size(page) - rec_size < BTR_CUR_PAGE_COMPRESS_LIMIT)
140
|| ((btr_page_get_next(page, mtr) == FIL_NULL)
141
&& (btr_page_get_prev(page, mtr) == FIL_NULL))
142
|| (page_get_n_recs(page) < 2)) {
144
/* The page fillfactor will drop below a predefined
145
minimum value, OR the level in the B-tree contains just
146
one page, OR the page will become empty: we recommend
147
compression if this is not the root page. */
149
return(dict_index_get_page(cursor->index)
150
== buf_frame_get_page_no(page));