~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/mtr/mtr0mtr.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "mtr0log.h"
18
18
#include "log0log.h"
19
19
 
 
20
/*******************************************************************
 
21
Starts a mini-transaction and creates a mini-transaction handle
 
22
and buffer in the memory buffer given by the caller. */
 
23
 
 
24
mtr_t*
 
25
mtr_start_noninline(
 
26
/*================*/
 
27
                        /* out: mtr buffer which also acts as
 
28
                        the mtr handle */
 
29
        mtr_t*  mtr)    /* in: memory buffer for the mtr buffer */
 
30
{
 
31
        return(mtr_start(mtr));
 
32
}
 
33
 
20
34
/*********************************************************************
21
35
Releases the item in the slot given. */
22
36
UNIV_INLINE
40
54
                } else if (type == MTR_MEMO_S_LOCK) {
41
55
                        rw_lock_s_unlock((rw_lock_t*)object);
42
56
#ifdef UNIV_DEBUG
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);
 
59
                } else {
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 */
 
63
#else
48
64
                } else {
49
65
                        rw_lock_x_unlock((rw_lock_t*)object);
 
66
#endif
50
67
                }
51
68
        }
52
69
 
147
164
 
148
165
/*******************************************************************
149
166
Commits a mini-transaction. */
150
 
UNIV_INTERN
 
167
 
151
168
void
152
169
mtr_commit(
153
170
/*=======*/
154
171
        mtr_t*  mtr)    /* in: mini-transaction */
155
172
{
156
 
        ibool           write_log;
157
 
 
158
173
        ut_ad(mtr);
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;
163
178
#endif
164
 
        write_log = mtr->modifications && mtr->n_log_recs;
165
 
 
166
 
        if (write_log) {
 
179
        if (mtr->modifications) {
167
180
                mtr_log_reserve_and_write(mtr);
168
181
        }
169
182
 
177
190
 
178
191
        mtr_memo_pop_all(mtr);
179
192
 
180
 
        if (write_log) {
 
193
        if (mtr->modifications) {
181
194
                log_release();
182
195
        }
183
196
 
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. */
195
 
UNIV_INTERN
 
208
 
196
209
void
197
210
mtr_rollback_to_savepoint(
198
211
/*======================*/
224
237
 
225
238
/*******************************************************
226
239
Releases an object in the memo stack. */
227
 
UNIV_INTERN
 
240
 
228
241
void
229
242
mtr_memo_release(
230
243
/*=============*/
260
273
 
261
274
/************************************************************
262
275
Reads 1 - 4 bytes from a file page buffered in the buffer pool. */
263
 
UNIV_INTERN
 
276
 
264
277
ulint
265
278
mtr_read_ulint(
266
279
/*===========*/
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 */
272
285
{
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),
 
288
                                MTR_MEMO_PAGE_S_FIX)
 
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) {
285
300
 
286
301
/************************************************************
287
302
Reads 8 bytes from a file page buffered in the buffer pool. */
288
 
UNIV_INTERN
 
303
 
289
304
dulint
290
305
mtr_read_dulint(
291
306
/*============*/
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 */
296
311
{
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));
 
313
        ut_ad(ptr && mtr);
 
314
        ut_ad(mtr_memo_contains(mtr, buf_block_align(ptr),
 
315
                                MTR_MEMO_PAGE_S_FIX)
 
316
              || mtr_memo_contains(mtr, buf_block_align(ptr),
 
317
                                   MTR_MEMO_PAGE_X_FIX));
300
318
        return(mach_read_from_8(ptr));
301
319
}
302
320
 
303
321
#ifdef UNIV_DEBUG
304
 
/**************************************************************
305
 
Checks if memo contains the given page. */
306
 
UNIV_INTERN
307
 
ibool
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 */
314
 
{
315
 
        ibool   ret;
316
 
 
317
 
        buf_pool_mutex_enter();
318
 
        ret = mtr_memo_contains(mtr, buf_block_align(ptr), type);
319
 
        buf_pool_mutex_exit();
320
 
        return(ret);
321
 
}
322
 
 
323
322
/*************************************************************
324
323
Prints info of an mtr handle. */
325
 
UNIV_INTERN
 
324
 
326
325
void
327
326
mtr_print(
328
327
/*======*/