9
9
#include "mach0data.h"
10
10
#include "mtr0mtr.h"
11
11
#include "mtr0log.h"
13
14
#define BTR_MAX_NODE_LEVEL 50 /* used in debug checking */
15
16
/******************************************************************
16
17
Gets a buffer page and declares its latching order level. */
22
ulint space, /* in: space id */
23
ulint zip_size, /* in: compressed page size in bytes
24
or 0 for uncompressed pages */
25
ulint page_no, /* in: page number */
26
ulint mode, /* in: latch mode */
27
mtr_t* mtr) /* in: mtr */
31
block = buf_page_get(space, zip_size, page_no, mode, mtr);
32
#ifdef UNIV_SYNC_DEBUG
33
if (mode != RW_NO_LATCH) {
35
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
41
/******************************************************************
42
Gets a buffer page and declares its latching order level. */
21
47
ulint space, /* in: space id */
48
ulint zip_size, /* in: compressed page size in bytes
49
or 0 for uncompressed pages */
22
50
ulint page_no, /* in: page number */
23
51
ulint mode, /* in: latch mode */
24
52
mtr_t* mtr) /* in: mtr */
28
page = buf_page_get(space, page_no, mode, mtr);
29
#ifdef UNIV_SYNC_DEBUG
30
if (mode != RW_NO_LATCH) {
32
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
54
return(buf_block_get_frame(btr_block_get(space, zip_size, page_no,
38
58
/******************************************************************
42
62
btr_page_set_index_id(
43
63
/*==================*/
44
64
page_t* page, /* in: page to be created */
65
page_zip_des_t* page_zip,/* in: compressed page whose uncompressed
66
part will be updated, or NULL */
45
67
dulint id, /* in: index id */
46
68
mtr_t* mtr) /* in: mtr */
48
mlog_write_dulint(page + PAGE_HEADER + PAGE_INDEX_ID, id, mtr);
70
if (UNIV_LIKELY_NULL(page_zip)) {
71
mach_write_to_8(page + (PAGE_HEADER + PAGE_INDEX_ID), id);
72
page_zip_write_header(page_zip,
73
page + (PAGE_HEADER + PAGE_INDEX_ID),
76
mlog_write_dulint(page + (PAGE_HEADER + PAGE_INDEX_ID),
51
81
/******************************************************************
67
97
btr_page_get_level_low(
68
98
/*===================*/
69
/* out: level, leaf level == 0 */
70
page_t* page) /* in: index page */
99
/* out: level, leaf level == 0 */
100
const page_t* page) /* in: index page */
87
117
btr_page_get_level(
88
118
/*===============*/
89
/* out: level, leaf level == 0 */
90
page_t* page, /* in: index page */
91
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
119
/* out: level, leaf level == 0 */
120
const page_t* page, /* in: index page */
121
mtr_t* mtr __attribute__((unused)))
122
/* in: mini-transaction handle */
93
124
ut_ad(page && mtr);
102
133
btr_page_set_level(
103
134
/*===============*/
104
page_t* page, /* in: index page */
105
ulint level, /* in: level, leaf level == 0 */
106
mtr_t* mtr) /* in: mini-transaction handle */
135
page_t* page, /* in: index page */
136
page_zip_des_t* page_zip,/* in: compressed page whose uncompressed
137
part will be updated, or NULL */
138
ulint level, /* in: level, leaf level == 0 */
139
mtr_t* mtr) /* in: mini-transaction handle */
108
141
ut_ad(page && mtr);
109
142
ut_ad(level <= BTR_MAX_NODE_LEVEL);
111
mlog_write_ulint(page + PAGE_HEADER + PAGE_LEVEL, level,
144
if (UNIV_LIKELY_NULL(page_zip)) {
145
mach_write_to_2(page + (PAGE_HEADER + PAGE_LEVEL), level);
146
page_zip_write_header(page_zip,
147
page + (PAGE_HEADER + PAGE_LEVEL),
150
mlog_write_ulint(page + (PAGE_HEADER + PAGE_LEVEL), level,
115
155
/************************************************************
119
159
btr_page_get_next(
120
160
/*==============*/
121
/* out: next page number */
122
page_t* page, /* in: index page */
123
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
161
/* out: next page number */
162
const page_t* page, /* in: index page */
163
mtr_t* mtr __attribute__((unused)))
164
/* in: mini-transaction handle */
125
166
ut_ad(page && mtr);
126
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
128
|| mtr_memo_contains(mtr, buf_block_align(page),
129
MTR_MEMO_PAGE_S_FIX));
167
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)
168
|| mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX));
131
170
return(mach_read_from_4(page + FIL_PAGE_NEXT));
138
177
btr_page_set_next(
139
178
/*==============*/
140
page_t* page, /* in: index page */
141
ulint next, /* in: next page number */
142
mtr_t* mtr) /* in: mini-transaction handle */
179
page_t* page, /* in: index page */
180
page_zip_des_t* page_zip,/* in: compressed page whose uncompressed
181
part will be updated, or NULL */
182
ulint next, /* in: next page number */
183
mtr_t* mtr) /* in: mini-transaction handle */
144
185
ut_ad(page && mtr);
146
mlog_write_ulint(page + FIL_PAGE_NEXT, next, MLOG_4BYTES, mtr);
187
if (UNIV_LIKELY_NULL(page_zip)) {
188
mach_write_to_4(page + FIL_PAGE_NEXT, next);
189
page_zip_write_header(page_zip, page + FIL_PAGE_NEXT, 4, mtr);
191
mlog_write_ulint(page + FIL_PAGE_NEXT, next, MLOG_4BYTES, mtr);
149
195
/************************************************************
153
199
btr_page_get_prev(
154
200
/*==============*/
155
/* out: prev page number */
156
page_t* page, /* in: index page */
201
/* out: prev page number */
202
const page_t* page, /* in: index page */
157
203
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
159
205
ut_ad(page && mtr);
168
214
btr_page_set_prev(
169
215
/*==============*/
170
page_t* page, /* in: index page */
171
ulint prev, /* in: previous page number */
172
mtr_t* mtr) /* in: mini-transaction handle */
216
page_t* page, /* in: index page */
217
page_zip_des_t* page_zip,/* in: compressed page whose uncompressed
218
part will be updated, or NULL */
219
ulint prev, /* in: previous page number */
220
mtr_t* mtr) /* in: mini-transaction handle */
174
222
ut_ad(page && mtr);
176
mlog_write_ulint(page + FIL_PAGE_PREV, prev, MLOG_4BYTES, mtr);
224
if (UNIV_LIKELY_NULL(page_zip)) {
225
mach_write_to_4(page + FIL_PAGE_PREV, prev);
226
page_zip_write_header(page_zip, page + FIL_PAGE_PREV, 4, mtr);
228
mlog_write_ulint(page + FIL_PAGE_PREV, prev, MLOG_4BYTES, mtr);
179
232
/******************************************************************
183
236
btr_node_ptr_get_child_page_no(
184
237
/*===========================*/
185
238
/* out: child node address */
186
rec_t* rec, /* in: node pointer record */
239
const rec_t* rec, /* in: node pointer record */
187
240
const ulint* offsets)/* in: array returned by rec_get_offsets() */
193
246
ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec));
205
258
"InnoDB: a nonsensical page number 0"
206
259
" in a node ptr record at offset %lu\n",
207
260
(ulong) page_offset(rec));
208
buf_page_print(buf_frame_align(rec));
261
buf_page_print(page_align(rec), 0);
218
271
btr_leaf_page_release(
219
272
/*==================*/
220
page_t* page, /* in: page */
221
ulint latch_mode, /* in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */
222
mtr_t* mtr) /* in: mtr */
273
buf_block_t* block, /* in: buffer block */
274
ulint latch_mode, /* in: BTR_SEARCH_LEAF or
276
mtr_t* mtr) /* in: mtr */
224
ut_ad(!mtr_memo_contains(mtr, buf_block_align(page),
226
if (latch_mode == BTR_SEARCH_LEAF) {
227
mtr_memo_release(mtr, buf_block_align(page),
228
MTR_MEMO_PAGE_S_FIX);
230
ut_ad(latch_mode == BTR_MODIFY_LEAF);
231
mtr_memo_release(mtr, buf_block_align(page),
232
MTR_MEMO_PAGE_X_FIX);
278
ut_ad(latch_mode == BTR_SEARCH_LEAF || latch_mode == BTR_MODIFY_LEAF);
279
ut_ad(!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY));
281
mtr_memo_release(mtr, block,
282
latch_mode == BTR_SEARCH_LEAF
283
? MTR_MEMO_PAGE_S_FIX
284
: MTR_MEMO_PAGE_X_FIX);