~fallenpegasus/drizzle/logcsv

« back to all changes in this revision

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

  • Committer: lbieber at stabletransit
  • Date: 2010-10-13 16:20:08 UTC
  • mfrom: (1843.1.3 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101013162008-qi2e6k5yvfm16964
Merge Stewart - update innobase plugin to be based on innodb_plugin 1.0.6
Merge Monty - more valgrind cleanup
Merge Monty - Moved libdrizzle api listings from doxygen to sphinx

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "mach0data.h"
28
28
#include "mtr0mtr.h"
29
29
 
 
30
#ifdef UNIV_LOG_DEBUG
30
31
/******************************************************//**
31
32
Checks by parsing that the catenated log segment for a single mtr is
32
33
consistent. */
34
35
ibool
35
36
log_check_log_recs(
36
37
/*===============*/
37
 
        byte*           buf,            /*!< in: pointer to the start of
 
38
        const byte*     buf,            /*!< in: pointer to the start of
38
39
                                        the log segment in the
39
40
                                        log_sys->buf log buffer */
40
41
        ulint           len,            /*!< in: segment length in bytes */
41
42
        ib_uint64_t     buf_start_lsn); /*!< in: buffer start lsn */
 
43
#endif /* UNIV_LOG_DEBUG */
42
44
 
43
45
/************************************************************//**
44
46
Gets a log block flush bit.
305
307
ib_uint64_t
306
308
log_reserve_and_write_fast(
307
309
/*=======================*/
308
 
        byte*           str,    /*!< in: string */
 
310
        const void*     str,    /*!< in: string */
309
311
        ulint           len,    /*!< in: string length */
310
 
        ib_uint64_t*    start_lsn,/*!< out: start lsn of the log record */
311
 
        ibool*          success)/*!< out: TRUE if success */
 
312
        ib_uint64_t*    start_lsn)/*!< out: start lsn of the log record */
312
313
{
313
 
        log_t*          log     = log_sys;
314
314
        ulint           data_len;
315
 
        ib_uint64_t     lsn;
316
 
 
317
 
        *success = TRUE;
318
 
 
319
 
        mutex_enter(&(log->mutex));
320
 
 
321
 
        data_len = len + log->buf_free % OS_FILE_LOG_BLOCK_SIZE;
 
315
#ifdef UNIV_LOG_LSN_DEBUG
 
316
        /* length of the LSN pseudo-record */
 
317
        ulint           lsn_len = 1
 
318
                + mach_get_compressed_size(log_sys->lsn >> 32)
 
319
                + mach_get_compressed_size(log_sys->lsn & 0xFFFFFFFFUL);
 
320
#endif /* UNIV_LOG_LSN_DEBUG */
 
321
 
 
322
        mutex_enter(&log_sys->mutex);
 
323
 
 
324
        data_len = len
 
325
#ifdef UNIV_LOG_LSN_DEBUG
 
326
                + lsn_len
 
327
#endif /* UNIV_LOG_LSN_DEBUG */
 
328
                + log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE;
322
329
 
323
330
        if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) {
324
331
 
325
332
                /* The string does not fit within the current log block
326
333
                or the log block would become full */
327
334
 
328
 
                *success = FALSE;
329
 
 
330
 
                mutex_exit(&(log->mutex));
 
335
                mutex_exit(&log_sys->mutex);
331
336
 
332
337
                return(0);
333
338
        }
334
339
 
335
 
        *start_lsn = log->lsn;
336
 
 
337
 
        ut_memcpy(log->buf + log->buf_free, str, len);
338
 
 
339
 
        log_block_set_data_len((byte*) ut_align_down(log->buf + log->buf_free,
 
340
        *start_lsn = log_sys->lsn;
 
341
 
 
342
#ifdef UNIV_LOG_LSN_DEBUG
 
343
        {
 
344
                /* Write the LSN pseudo-record. */
 
345
                byte* b = &log_sys->buf[log_sys->buf_free];
 
346
                *b++ = MLOG_LSN | (MLOG_SINGLE_REC_FLAG & *(const byte*) str);
 
347
                /* Write the LSN in two parts,
 
348
                as a pseudo page number and space id. */
 
349
                b += mach_write_compressed(b, log_sys->lsn >> 32);
 
350
                b += mach_write_compressed(b, log_sys->lsn & 0xFFFFFFFFUL);
 
351
                ut_a(b - lsn_len == &log_sys->buf[log_sys->buf_free]);
 
352
 
 
353
                memcpy(b, str, len);
 
354
                len += lsn_len;
 
355
        }
 
356
#else /* UNIV_LOG_LSN_DEBUG */
 
357
        memcpy(log_sys->buf + log_sys->buf_free, str, len);
 
358
#endif /* UNIV_LOG_LSN_DEBUG */
 
359
 
 
360
        log_block_set_data_len((byte*) ut_align_down(log_sys->buf
 
361
                                                     + log_sys->buf_free,
340
362
                                                     OS_FILE_LOG_BLOCK_SIZE),
341
363
                               data_len);
342
364
#ifdef UNIV_LOG_DEBUG
343
 
        log->old_buf_free = log->buf_free;
344
 
        log->old_lsn = log->lsn;
 
365
        log_sys->old_buf_free = log_sys->buf_free;
 
366
        log_sys->old_lsn = log_sys->lsn;
345
367
#endif
346
 
        log->buf_free += len;
347
 
 
348
 
        ut_ad(log->buf_free <= log->buf_size);
349
 
 
350
 
        lsn = log->lsn += len;
 
368
        log_sys->buf_free += len;
 
369
 
 
370
        ut_ad(log_sys->buf_free <= log_sys->buf_size);
 
371
 
 
372
        log_sys->lsn += len;
351
373
 
352
374
#ifdef UNIV_LOG_DEBUG
353
 
        log_check_log_recs(log->buf + log->old_buf_free,
354
 
                           log->buf_free - log->old_buf_free, log->old_lsn);
 
375
        log_check_log_recs(log_sys->buf + log_sys->old_buf_free,
 
376
                           log_sys->buf_free - log_sys->old_buf_free,
 
377
                           log_sys->old_lsn);
355
378
#endif
356
 
        return(lsn);
 
379
        return(log_sys->lsn);
357
380
}
358
381
 
359
382
/***********************************************************************//**