~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/trx0rseg.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file include/trx0rseg.h
 
21
Rollback segment
 
22
 
 
23
Created 3/26/1996 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
#ifndef trx0rseg_h
 
27
#define trx0rseg_h
 
28
 
 
29
#include "univ.i"
 
30
#include "trx0types.h"
 
31
#include "trx0sys.h"
 
32
 
 
33
/******************************************************************//**
 
34
Gets a rollback segment header.
 
35
@return rollback segment header, page x-latched */
 
36
UNIV_INLINE
 
37
trx_rsegf_t*
 
38
trx_rsegf_get(
 
39
/*==========*/
 
40
        ulint   space,          /*!< in: space where placed */
 
41
        ulint   zip_size,       /*!< in: compressed page size in bytes
 
42
                                or 0 for uncompressed pages */
 
43
        ulint   page_no,        /*!< in: page number of the header */
 
44
        mtr_t*  mtr);           /*!< in: mtr */
 
45
/******************************************************************//**
 
46
Gets a newly created rollback segment header.
 
47
@return rollback segment header, page x-latched */
 
48
UNIV_INLINE
 
49
trx_rsegf_t*
 
50
trx_rsegf_get_new(
 
51
/*==============*/
 
52
        ulint   space,          /*!< in: space where placed */
 
53
        ulint   zip_size,       /*!< in: compressed page size in bytes
 
54
                                or 0 for uncompressed pages */
 
55
        ulint   page_no,        /*!< in: page number of the header */
 
56
        mtr_t*  mtr);           /*!< in: mtr */
 
57
/***************************************************************//**
 
58
Gets the file page number of the nth undo log slot.
 
59
@return page number of the undo log segment */
 
60
UNIV_INLINE
 
61
ulint
 
62
trx_rsegf_get_nth_undo(
 
63
/*===================*/
 
64
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
 
65
        ulint           n,      /*!< in: index of slot */
 
66
        mtr_t*          mtr);   /*!< in: mtr */
 
67
/***************************************************************//**
 
68
Sets the file page number of the nth undo log slot. */
 
69
UNIV_INLINE
 
70
void
 
71
trx_rsegf_set_nth_undo(
 
72
/*===================*/
 
73
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
 
74
        ulint           n,      /*!< in: index of slot */
 
75
        ulint           page_no,/*!< in: page number of the undo log segment */
 
76
        mtr_t*          mtr);   /*!< in: mtr */
 
77
/****************************************************************//**
 
78
Looks for a free slot for an undo log segment.
 
79
@return slot index or ULINT_UNDEFINED if not found */
 
80
UNIV_INLINE
 
81
ulint
 
82
trx_rsegf_undo_find_free(
 
83
/*=====================*/
 
84
        trx_rsegf_t*    rsegf,  /*!< in: rollback segment header */
 
85
        mtr_t*          mtr);   /*!< in: mtr */
 
86
/******************************************************************//**
 
87
Looks for a rollback segment, based on the rollback segment id.
 
88
@return rollback segment */
 
89
UNIV_INTERN
 
90
trx_rseg_t*
 
91
trx_rseg_get_on_id(
 
92
/*===============*/
 
93
        ulint   id);    /*!< in: rollback segment id */
 
94
/****************************************************************//**
 
95
Creates a rollback segment header. This function is called only when
 
96
a new rollback segment is created in the database.
 
97
@return page number of the created segment, FIL_NULL if fail */
 
98
UNIV_INTERN
 
99
ulint
 
100
trx_rseg_header_create(
 
101
/*===================*/
 
102
        ulint   space,          /*!< in: space id */
 
103
        ulint   zip_size,       /*!< in: compressed page size in bytes
 
104
                                or 0 for uncompressed pages */
 
105
        ulint   max_size,       /*!< in: max size in pages */
 
106
        ulint*  slot_no,        /*!< out: rseg id == slot number in trx sys */
 
107
        mtr_t*  mtr);           /*!< in: mtr */
 
108
/*********************************************************************//**
 
109
Creates the memory copies for rollback segments and initializes the
 
110
rseg list and array in trx_sys at a database startup. */
 
111
UNIV_INTERN
 
112
void
 
113
trx_rseg_list_and_array_init(
 
114
/*=========================*/
 
115
        trx_sysf_t*     sys_header,     /*!< in: trx system header */
 
116
        mtr_t*          mtr);           /*!< in: mtr */
 
117
/****************************************************************//**
 
118
Creates a new rollback segment to the database.
 
119
@return the created segment object, NULL if fail */
 
120
UNIV_INTERN
 
121
trx_rseg_t*
 
122
trx_rseg_create(
 
123
/*============*/
 
124
        ulint   space,          /*!< in: space id */
 
125
        ulint   max_size,       /*!< in: max size in pages */
 
126
        ulint*  id,             /*!< out: rseg id */
 
127
        mtr_t*  mtr);           /*!< in: mtr */
 
128
/***************************************************************************
 
129
Free's an instance of the rollback segment in memory. */
 
130
UNIV_INTERN
 
131
void
 
132
trx_rseg_mem_free(
 
133
/*==============*/
 
134
        trx_rseg_t*     rseg);          /* in, own: instance to free */
 
135
 
 
136
 
 
137
/* Number of undo log slots in a rollback segment file copy */
 
138
#define TRX_RSEG_N_SLOTS        (UNIV_PAGE_SIZE / 16)
 
139
 
 
140
/* Maximum number of transactions supported by a single rollback segment */
 
141
#define TRX_RSEG_MAX_N_TRXS     (TRX_RSEG_N_SLOTS / 2)
 
142
 
 
143
/* The rollback segment memory object */
 
144
struct trx_rseg_struct{
 
145
        /*--------------------------------------------------------*/
 
146
        ulint           id;     /*!< rollback segment id == the index of
 
147
                                its slot in the trx system file copy */
 
148
        mutex_t         mutex;  /*!< mutex protecting the fields in this
 
149
                                struct except id; NOTE that the latching
 
150
                                order must always be kernel mutex ->
 
151
                                rseg mutex */
 
152
        ulint           space;  /*!< space where the rollback segment is
 
153
                                header is placed */
 
154
        ulint           zip_size;/* compressed page size of space
 
155
                                in bytes, or 0 for uncompressed spaces */
 
156
        ulint           page_no;/* page number of the rollback segment
 
157
                                header */
 
158
        ulint           max_size;/* maximum allowed size in pages */
 
159
        ulint           curr_size;/* current size in pages */
 
160
        /*--------------------------------------------------------*/
 
161
        /* Fields for update undo logs */
 
162
        UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list;
 
163
                                        /* List of update undo logs */
 
164
        UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_cached;
 
165
                                        /* List of update undo log segments
 
166
                                        cached for fast reuse */
 
167
        /*--------------------------------------------------------*/
 
168
        /* Fields for insert undo logs */
 
169
        UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;
 
170
                                        /* List of insert undo logs */
 
171
        UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;
 
172
                                        /* List of insert undo log segments
 
173
                                        cached for fast reuse */
 
174
        /*--------------------------------------------------------*/
 
175
        ulint           last_page_no;   /*!< Page number of the last not yet
 
176
                                        purged log header in the history list;
 
177
                                        FIL_NULL if all list purged */
 
178
        ulint           last_offset;    /*!< Byte offset of the last not yet
 
179
                                        purged log header */
 
180
        trx_id_t        last_trx_no;    /*!< Transaction number of the last not
 
181
                                        yet purged log */
 
182
        ibool           last_del_marks; /*!< TRUE if the last not yet purged log
 
183
                                        needs purging */
 
184
        /*--------------------------------------------------------*/
 
185
        UT_LIST_NODE_T(trx_rseg_t) rseg_list;
 
186
                                        /* the list of the rollback segment
 
187
                                        memory objects */
 
188
};
 
189
 
 
190
/* Undo log segment slot in a rollback segment header */
 
191
/*-------------------------------------------------------------*/
 
192
#define TRX_RSEG_SLOT_PAGE_NO   0       /* Page number of the header page of
 
193
                                        an undo log segment */
 
194
/*-------------------------------------------------------------*/
 
195
/* Slot size */
 
196
#define TRX_RSEG_SLOT_SIZE      4
 
197
 
 
198
/* The offset of the rollback segment header on its page */
 
199
#define TRX_RSEG                FSEG_PAGE_DATA
 
200
 
 
201
/* Transaction rollback segment header */
 
202
/*-------------------------------------------------------------*/
 
203
#define TRX_RSEG_MAX_SIZE       0       /* Maximum allowed size for rollback
 
204
                                        segment in pages */
 
205
#define TRX_RSEG_HISTORY_SIZE   4       /* Number of file pages occupied
 
206
                                        by the logs in the history list */
 
207
#define TRX_RSEG_HISTORY        8       /* The update undo logs for committed
 
208
                                        transactions */
 
209
#define TRX_RSEG_FSEG_HEADER    (8 + FLST_BASE_NODE_SIZE)
 
210
                                        /* Header for the file segment where
 
211
                                        this page is placed */
 
212
#define TRX_RSEG_UNDO_SLOTS     (8 + FLST_BASE_NODE_SIZE + FSEG_HEADER_SIZE)
 
213
                                        /* Undo log segment slots */
 
214
/*-------------------------------------------------------------*/
 
215
 
 
216
#ifndef UNIV_NONINL
 
217
#include "trx0rseg.ic"
 
218
#endif
 
219
 
 
220
#endif