~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Stewart's dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1996, 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/trx0rseg.ic
21
 
Rollback segment
22
 
 
23
 
Created 3/26/1996 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#include "srv0srv.h"
27
 
#include "mtr0log.h"
28
 
 
29
 
/******************************************************************//**
30
 
Gets a rollback segment header.
31
 
@return rollback segment header, page x-latched */
32
 
UNIV_INLINE
33
 
trx_rsegf_t*
34
 
trx_rsegf_get(
35
 
/*==========*/
36
 
        ulint   space,          /*!< in: space where placed */
37
 
        ulint   zip_size,       /*!< in: compressed page size in bytes
38
 
                                or 0 for uncompressed pages */
39
 
        ulint   page_no,        /*!< in: page number of the header */
40
 
        mtr_t*  mtr)            /*!< in: mtr */
41
 
{
42
 
        buf_block_t*    block;
43
 
        trx_rsegf_t*    header;
44
 
 
45
 
        block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
46
 
        buf_block_dbg_add_level(block, SYNC_RSEG_HEADER);
47
 
 
48
 
        header = TRX_RSEG + buf_block_get_frame(block);
49
 
 
50
 
        return(header);
51
 
}
52
 
 
53
 
/******************************************************************//**
54
 
Gets a newly created rollback segment header.
55
 
@return rollback segment header, page x-latched */
56
 
UNIV_INLINE
57
 
trx_rsegf_t*
58
 
trx_rsegf_get_new(
59
 
/*==============*/
60
 
        ulint   space,          /*!< in: space where placed */
61
 
        ulint   zip_size,       /*!< in: compressed page size in bytes
62
 
                                or 0 for uncompressed pages */
63
 
        ulint   page_no,        /*!< in: page number of the header */
64
 
        mtr_t*  mtr)            /*!< in: mtr */
65
 
{
66
 
        buf_block_t*    block;
67
 
        trx_rsegf_t*    header;
68
 
 
69
 
        block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
70
 
        buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
71
 
 
72
 
        header = TRX_RSEG + buf_block_get_frame(block);
73
 
 
74
 
        return(header);
75
 
}
76
 
 
77
 
/***************************************************************//**
78
 
Gets the file page number of the nth undo log slot.
79
 
@return page number of the undo log segment */
80
 
UNIV_INLINE
81
 
ulint
82
 
trx_rsegf_get_nth_undo(
83
 
/*===================*/
84
 
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
85
 
        ulint           n,      /*!< in: index of slot */
86
 
        mtr_t*          mtr)    /*!< in: mtr */
87
 
{
88
 
        if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) {
89
 
                fprintf(stderr,
90
 
                        "InnoDB: Error: trying to get slot %lu of rseg\n",
91
 
                        (ulong) n);
92
 
                ut_error;
93
 
        }
94
 
 
95
 
        return(mtr_read_ulint(rsegf + TRX_RSEG_UNDO_SLOTS
96
 
                              + n * TRX_RSEG_SLOT_SIZE, MLOG_4BYTES, mtr));
97
 
}
98
 
 
99
 
/***************************************************************//**
100
 
Sets the file page number of the nth undo log slot. */
101
 
UNIV_INLINE
102
 
void
103
 
trx_rsegf_set_nth_undo(
104
 
/*===================*/
105
 
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
106
 
        ulint           n,      /*!< in: index of slot */
107
 
        ulint           page_no,/*!< in: page number of the undo log segment */
108
 
        mtr_t*          mtr)    /*!< in: mtr */
109
 
{
110
 
        if (UNIV_UNLIKELY(n >= TRX_RSEG_N_SLOTS)) {
111
 
                fprintf(stderr,
112
 
                        "InnoDB: Error: trying to set slot %lu of rseg\n",
113
 
                        (ulong) n);
114
 
                ut_error;
115
 
        }
116
 
 
117
 
        mlog_write_ulint(rsegf + TRX_RSEG_UNDO_SLOTS + n * TRX_RSEG_SLOT_SIZE,
118
 
                         page_no, MLOG_4BYTES, mtr);
119
 
}
120
 
 
121
 
/****************************************************************//**
122
 
Looks for a free slot for an undo log segment.
123
 
@return slot index or ULINT_UNDEFINED if not found */
124
 
UNIV_INLINE
125
 
ulint
126
 
trx_rsegf_undo_find_free(
127
 
/*=====================*/
128
 
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
129
 
        mtr_t*          mtr)    /*!< in: mtr */
130
 
{
131
 
        ulint           i;
132
 
        ulint           page_no;
133
 
 
134
 
        for (i = 0; i < TRX_RSEG_N_SLOTS; i++) {
135
 
 
136
 
                page_no = trx_rsegf_get_nth_undo(rsegf, i, mtr);
137
 
 
138
 
                if (page_no == FIL_NULL) {
139
 
 
140
 
                        return(i);
141
 
                }
142
 
        }
143
 
 
144
 
        return(ULINT_UNDEFINED);
145
 
}