17
17
#include "mtr0log.h"
18
18
#include "log0log.h"
20
/*******************************************************************
21
Starts a mini-transaction and creates a mini-transaction handle
22
and buffer in the memory buffer given by the caller. */
27
/* out: mtr buffer which also acts as
29
mtr_t* mtr) /* in: memory buffer for the mtr buffer */
31
return(mtr_start(mtr));
20
34
/*********************************************************************
21
35
Releases the item in the slot given. */
40
54
} else if (type == MTR_MEMO_S_LOCK) {
41
55
rw_lock_s_unlock((rw_lock_t*)object);
43
} else if (type != MTR_MEMO_X_LOCK) {
57
} else if (type == MTR_MEMO_X_LOCK) {
58
rw_lock_x_unlock((rw_lock_t*)object);
44
60
ut_ad(type == MTR_MEMO_MODIFY);
45
61
ut_ad(mtr_memo_contains(mtr, object,
46
62
MTR_MEMO_PAGE_X_FIX));
47
#endif /* UNIV_DEBUG */
49
65
rw_lock_x_unlock((rw_lock_t*)object);
148
165
/*******************************************************************
149
166
Commits a mini-transaction. */
154
171
mtr_t* mtr) /* in: mini-transaction */
159
174
ut_ad(mtr->magic_n == MTR_MAGIC_N);
160
175
ut_ad(mtr->state == MTR_ACTIVE);
161
176
#ifdef UNIV_DEBUG
162
177
mtr->state = MTR_COMMITTING;
164
write_log = mtr->modifications && mtr->n_log_recs;
179
if (mtr->modifications) {
167
180
mtr_log_reserve_and_write(mtr);
192
205
Releases the latches stored in an mtr memo down to a savepoint.
193
206
NOTE! The mtr must not have made changes to buffer pages after the
194
207
savepoint, as these can be handled only by mtr_commit. */
197
210
mtr_rollback_to_savepoint(
198
211
/*======================*/
261
274
/************************************************************
262
275
Reads 1 - 4 bytes from a file page buffered in the buffer pool. */
267
280
/* out: value read */
268
const byte* ptr, /* in: pointer from where to read */
281
byte* ptr, /* in: pointer from where to read */
269
282
ulint type, /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
270
283
mtr_t* mtr __attribute__((unused)))
271
284
/* in: mini-transaction handle */
273
286
ut_ad(mtr->state == MTR_ACTIVE);
274
ut_ad(mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_S_FIX)
275
|| mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_X_FIX));
287
ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr),
289
|| mtr_memo_contains(mtr, buf_block_align(ptr),
290
MTR_MEMO_PAGE_X_FIX));
276
291
if (type == MLOG_1BYTE) {
277
292
return(mach_read_from_1(ptr));
278
293
} else if (type == MLOG_2BYTES) {
286
301
/************************************************************
287
302
Reads 8 bytes from a file page buffered in the buffer pool. */
292
307
/* out: value read */
293
const byte* ptr, /* in: pointer from where to read */
308
byte* ptr, /* in: pointer from where to read */
294
309
mtr_t* mtr __attribute__((unused)))
295
310
/* in: mini-transaction handle */
297
312
ut_ad(mtr->state == MTR_ACTIVE);
298
ut_ad(mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_S_FIX)
299
|| mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_X_FIX));
314
ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr),
316
|| mtr_memo_contains(mtr, buf_block_align(ptr),
317
MTR_MEMO_PAGE_X_FIX));
300
318
return(mach_read_from_8(ptr));
303
321
#ifdef UNIV_DEBUG
304
/**************************************************************
305
Checks if memo contains the given page. */
308
mtr_memo_contains_page(
309
/*===================*/
310
/* out: TRUE if contains */
311
mtr_t* mtr, /* in: mtr */
312
const byte* ptr, /* in: pointer to buffer frame */
313
ulint type) /* in: type of object */
317
buf_pool_mutex_enter();
318
ret = mtr_memo_contains(mtr, buf_block_align(ptr), type);
319
buf_pool_mutex_exit();
323
322
/*************************************************************
324
323
Prints info of an mtr handle. */