~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/btr0cur.ic

  • Committer: Brian Aker
  • Date: 2010-09-28 06:27:36 UTC
  • mto: (1800.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 1801.
  • Revision ID: brian@tangent.org-20100928062736-65a8ufnsji93fd99
Remove additional (maybe last of?) native_handle actual calls (safe_mutex is
historical and unused, so it does not count).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
4
 
 
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.
8
 
 
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.
12
 
 
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
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/btr0cur.ic
21
 
The index tree cursor
22
 
 
23
 
Created 10/16/1994 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef UNIV_HOTBACKUP
27
 
#include "btr0btr.h"
28
 
 
29
 
#ifdef UNIV_DEBUG
30
 
/*********************************************************//**
31
 
Returns the page cursor component of a tree cursor.
32
 
@return pointer to page cursor component */
33
 
UNIV_INLINE
34
 
page_cur_t*
35
 
btr_cur_get_page_cur(
36
 
/*=================*/
37
 
        const btr_cur_t*        cursor) /*!< in: tree cursor */
38
 
{
39
 
        return(&((btr_cur_t*) cursor)->page_cur);
40
 
}
41
 
#endif /* UNIV_DEBUG */
42
 
/*********************************************************//**
43
 
Returns the buffer block on which the tree cursor is positioned.
44
 
@return pointer to buffer block */
45
 
UNIV_INLINE
46
 
buf_block_t*
47
 
btr_cur_get_block(
48
 
/*==============*/
49
 
        btr_cur_t*      cursor) /*!< in: tree cursor */
50
 
{
51
 
        return(page_cur_get_block(btr_cur_get_page_cur(cursor)));
52
 
}
53
 
 
54
 
/*********************************************************//**
55
 
Returns the record pointer of a tree cursor.
56
 
@return pointer to record */
57
 
UNIV_INLINE
58
 
rec_t*
59
 
btr_cur_get_rec(
60
 
/*============*/
61
 
        btr_cur_t*      cursor) /*!< in: tree cursor */
62
 
{
63
 
        return(page_cur_get_rec(&(cursor->page_cur)));
64
 
}
65
 
 
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 */
69
 
UNIV_INLINE
70
 
page_zip_des_t*
71
 
btr_cur_get_page_zip(
72
 
/*=================*/
73
 
        btr_cur_t*      cursor) /*!< in: tree cursor */
74
 
{
75
 
        return(buf_block_get_page_zip(btr_cur_get_block(cursor)));
76
 
}
77
 
 
78
 
/*********************************************************//**
79
 
Invalidates a tree cursor by setting record pointer to NULL. */
80
 
UNIV_INLINE
81
 
void
82
 
btr_cur_invalidate(
83
 
/*===============*/
84
 
        btr_cur_t*      cursor) /*!< in: tree cursor */
85
 
{
86
 
        page_cur_invalidate(&(cursor->page_cur));
87
 
}
88
 
 
89
 
/*********************************************************//**
90
 
Returns the page of a tree cursor.
91
 
@return pointer to page */
92
 
UNIV_INLINE
93
 
page_t*
94
 
btr_cur_get_page(
95
 
/*=============*/
96
 
        btr_cur_t*      cursor) /*!< in: tree cursor */
97
 
{
98
 
        return(page_align(page_cur_get_rec(&(cursor->page_cur))));
99
 
}
100
 
 
101
 
/*********************************************************//**
102
 
Returns the index of a cursor.
103
 
@return index */
104
 
UNIV_INLINE
105
 
dict_index_t*
106
 
btr_cur_get_index(
107
 
/*==============*/
108
 
        btr_cur_t*      cursor) /*!< in: B-tree cursor */
109
 
{
110
 
        return(cursor->index);
111
 
}
112
 
 
113
 
/*********************************************************//**
114
 
Positions a tree cursor at a given record. */
115
 
UNIV_INLINE
116
 
void
117
 
btr_cur_position(
118
 
/*=============*/
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 */
123
 
{
124
 
        ut_ad(page_align(rec) == block->frame);
125
 
 
126
 
        page_cur_position(rec, block, btr_cur_get_page_cur(cursor));
127
 
 
128
 
        cursor->index = index;
129
 
}
130
 
 
131
 
/*********************************************************************//**
132
 
Checks if compressing an index page where a btr cursor is placed makes
133
 
sense.
134
 
@return TRUE if compression is recommended */
135
 
UNIV_INLINE
136
 
ibool
137
 
btr_cur_compress_recommendation(
138
 
/*============================*/
139
 
        btr_cur_t*      cursor, /*!< in: btr cursor */
140
 
        mtr_t*          mtr)    /*!< in: mtr */
141
 
{
142
 
        page_t*         page;
143
 
 
144
 
        ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
145
 
                                MTR_MEMO_PAGE_X_FIX));
146
 
 
147
 
        page = btr_cur_get_page(cursor);
148
 
 
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))) {
152
 
 
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
156
 
                root page. */
157
 
 
158
 
                return(dict_index_get_page(cursor->index)
159
 
                       != page_get_page_no(page));
160
 
        }
161
 
 
162
 
        return(FALSE);
163
 
}
164
 
 
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 */
169
 
UNIV_INLINE
170
 
ibool
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 */
176
 
{
177
 
        page_t*         page;
178
 
 
179
 
        ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
180
 
                                MTR_MEMO_PAGE_X_FIX));
181
 
 
182
 
        page = btr_cur_get_page(cursor);
183
 
 
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)) {
188
 
 
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. */
193
 
 
194
 
                return(dict_index_get_page(cursor->index)
195
 
                       == page_get_page_no(page));
196
 
        }
197
 
 
198
 
        return(TRUE);
199
 
}
200
 
#endif /* !UNIV_HOTBACKUP */