InnoDB Plugin  1.0
trx0rseg.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2011, Oracle and/or its affiliates. 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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef trx0rseg_h
27 #define trx0rseg_h
28 
29 #include "univ.i"
30 #include "trx0types.h"
31 #include "trx0sys.h"
32 #include "ut0bh.h"
33 
34 /******************************************************************/
37 UNIV_INLINE
40 /*==========*/
41  ulint space,
42  ulint zip_size,
44  ulint page_no,
45  mtr_t* mtr);
46 /******************************************************************/
49 UNIV_INLINE
52 /*==============*/
53  ulint space,
54  ulint zip_size,
56  ulint page_no,
57  mtr_t* mtr);
58 /***************************************************************/
61 UNIV_INLINE
62 ulint
64 /*===================*/
65  trx_rsegf_t* rsegf,
66  ulint n,
67  mtr_t* mtr);
68 /***************************************************************/
70 UNIV_INLINE
71 void
73 /*===================*/
74  trx_rsegf_t* rsegf,
75  ulint n,
76  ulint page_no,
77  mtr_t* mtr);
78 /****************************************************************/
81 UNIV_INLINE
82 ulint
84 /*=====================*/
85  trx_rsegf_t* rsegf,
86  mtr_t* mtr);
87 /******************************************************************/
90 UNIV_INLINE
93 /*===============*/
94  ulint id);
95 /****************************************************************/
99 UNIV_INTERN
100 ulint
102 /*===================*/
103  ulint space,
104  ulint zip_size,
106  ulint max_size,
107  ulint rseg_slot_no,
108  mtr_t* mtr);
109 /*********************************************************************/
112 UNIV_INTERN
113 void
115 /*================*/
116  trx_sysf_t* sys_header,
117  ib_bh_t* ib_bh,
118  mtr_t* mtr);
119 /***************************************************************************
120 Free's an instance of the rollback segment in memory. */
121 UNIV_INTERN
122 void
124 /*==============*/
125  trx_rseg_t* rseg);
127 /*********************************************************************
128 Creates a rollback segment. */
129 UNIV_INTERN
130 trx_rseg_t*
132 /*============*/
133  ulint space);
135 /********************************************************************
136 Get the number of unique rollback tablespaces in use except space id 0.
137 The last space id will be the sentinel value ULINT_UNDEFINED. The array
138 will be sorted on space id. Note: space_ids should have have space for
139 TRX_SYS_N_RSEGS + 1 elements.
140 @return number of unique rollback tablespaces in use. */
141 UNIV_INTERN
142 ulint
144 /*============================*/
145  ulint* space_ids);
147 /* Number of undo log slots in a rollback segment file copy */
148 #define TRX_RSEG_N_SLOTS (UNIV_PAGE_SIZE / 16)
149 
150 /* Maximum number of transactions supported by a single rollback segment */
151 #define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2)
152 
153 /* The rollback segment memory object */
154 struct trx_rseg_t{
155  /*--------------------------------------------------------*/
156  ulint id;
160  ulint space;
162  ulint zip_size;/* compressed page size of space
163  in bytes, or 0 for uncompressed spaces */
164  ulint page_no;/* page number of the rollback segment
165  header */
166  ulint max_size;/* maximum allowed size in pages */
167  ulint curr_size;/* current size in pages */
168  /*--------------------------------------------------------*/
169  /* Fields for update undo logs */
170  UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list;
171  /* List of update undo logs */
172  UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_cached;
173  /* List of update undo log segments
174  cached for fast reuse */
175  /*--------------------------------------------------------*/
176  /* Fields for insert undo logs */
177  UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;
178  /* List of insert undo logs */
179  UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;
180  /* List of insert undo log segments
181  cached for fast reuse */
182  /*--------------------------------------------------------*/
183  ulint last_page_no;
186  ulint last_offset;
192 };
193 
195 struct rseg_queue_t {
198 };
199 
200 /* Undo log segment slot in a rollback segment header */
201 /*-------------------------------------------------------------*/
202 #define TRX_RSEG_SLOT_PAGE_NO 0 /* Page number of the header page of
203  an undo log segment */
204 /*-------------------------------------------------------------*/
205 /* Slot size */
206 #define TRX_RSEG_SLOT_SIZE 4
207 
208 /* The offset of the rollback segment header on its page */
209 #define TRX_RSEG FSEG_PAGE_DATA
210 
211 /* Transaction rollback segment header */
212 /*-------------------------------------------------------------*/
213 #define TRX_RSEG_MAX_SIZE 0 /* Maximum allowed size for rollback
214  segment in pages */
215 #define TRX_RSEG_HISTORY_SIZE 4 /* Number of file pages occupied
216  by the logs in the history list */
217 #define TRX_RSEG_HISTORY 8 /* The update undo logs for committed
218  transactions */
219 #define TRX_RSEG_FSEG_HEADER (8 + FLST_BASE_NODE_SIZE)
220  /* Header for the file segment where
221  this page is placed */
222 #define TRX_RSEG_UNDO_SLOTS (8 + FLST_BASE_NODE_SIZE + FSEG_HEADER_SIZE)
223  /* Undo log segment slots */
224 /*-------------------------------------------------------------*/
225 
226 #ifndef UNIV_NONINL
227 #include "trx0rseg.ic"
228 #endif
229 
230 #endif