InnoDB Plugin  1.0
mtr0mtr.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2012, Facebook Inc.
5 
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17 
18 *****************************************************************************/
19 
20 /**************************************************/
27 #ifndef mtr0mtr_h
28 #define mtr0mtr_h
29 
30 #include "univ.i"
31 #include "mem0mem.h"
32 #include "dyn0dyn.h"
33 #include "buf0types.h"
34 #include "sync0rw.h"
35 #include "ut0byte.h"
36 #include "mtr0types.h"
37 #include "page0types.h"
38 
39 /* Logging modes for a mini-transaction */
40 #define MTR_LOG_ALL 21 /* default mode: log all operations
41  modifying disk-based data */
42 #define MTR_LOG_NONE 22 /* log no operations */
43 #define MTR_LOG_NO_REDO 23 /* Don't generate REDO */
44 /*#define MTR_LOG_SPACE 23 */ /* log only operations modifying
45  file space page allocation data
46  (operations in fsp0fsp.* ) */
47 #define MTR_LOG_SHORT_INSERTS 24 /* inserts are logged in a shorter
48  form */
49 
50 /* Types for the mlock objects to store in the mtr memo; NOTE that the
51 first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
52 #define MTR_MEMO_PAGE_S_FIX RW_S_LATCH
53 #define MTR_MEMO_PAGE_X_FIX RW_X_LATCH
54 #define MTR_MEMO_BUF_FIX RW_NO_LATCH
55 #ifdef UNIV_DEBUG
56 # define MTR_MEMO_MODIFY 54
57 #endif /* UNIV_DEBUG */
58 #define MTR_MEMO_S_LOCK 55
59 #define MTR_MEMO_X_LOCK 56
60 
65 #define MLOG_SINGLE_REC_FLAG 128
71 #define MLOG_1BYTE (1)
72 #define MLOG_2BYTES (2)
73 #define MLOG_4BYTES (4)
74 #define MLOG_8BYTES (8)
75 #define MLOG_REC_INSERT ((byte)9)
76 #define MLOG_REC_CLUST_DELETE_MARK ((byte)10)
78 #define MLOG_REC_SEC_DELETE_MARK ((byte)11)
80 #define MLOG_REC_UPDATE_IN_PLACE ((byte)13)
82 #define MLOG_REC_DELETE ((byte)14)
84 #define MLOG_LIST_END_DELETE ((byte)15)
86 #define MLOG_LIST_START_DELETE ((byte)16)
88 #define MLOG_LIST_END_COPY_CREATED ((byte)17)
90 #define MLOG_PAGE_REORGANIZE ((byte)18)
93 #define MLOG_PAGE_CREATE ((byte)19)
94 #define MLOG_UNDO_INSERT ((byte)20)
96 #define MLOG_UNDO_ERASE_END ((byte)21)
98 #define MLOG_UNDO_INIT ((byte)22)
100 #define MLOG_UNDO_HDR_DISCARD ((byte)23)
102 #define MLOG_UNDO_HDR_REUSE ((byte)24)
104 #define MLOG_UNDO_HDR_CREATE ((byte)25)
106 #define MLOG_REC_MIN_MARK ((byte)26)
110 #define MLOG_IBUF_BITMAP_INIT ((byte)27)
112 /*#define MLOG_FULL_PAGE ((byte)28) full contents of a page */
113 #ifdef UNIV_LOG_LSN_DEBUG
114 # define MLOG_LSN ((byte)28) /* current LSN */
115 #endif
116 #define MLOG_INIT_FILE_PAGE ((byte)29)
125 #define MLOG_WRITE_STRING ((byte)30)
127 #define MLOG_MULTI_REC_END ((byte)31)
131 #define MLOG_DUMMY_RECORD ((byte)32)
133 #define MLOG_FILE_CREATE ((byte)33)
135 #define MLOG_FILE_RENAME ((byte)34)
137 #define MLOG_FILE_DELETE ((byte)35)
139 #define MLOG_COMP_REC_MIN_MARK ((byte)36)
143 #define MLOG_COMP_PAGE_CREATE ((byte)37)
145 #define MLOG_COMP_REC_INSERT ((byte)38)
146 #define MLOG_COMP_REC_CLUST_DELETE_MARK ((byte)39)
147 
150 #define MLOG_COMP_REC_SEC_DELETE_MARK ((byte)40)
158 #define MLOG_COMP_REC_UPDATE_IN_PLACE ((byte)41)
162 #define MLOG_COMP_REC_DELETE ((byte)42)
164 #define MLOG_COMP_LIST_END_DELETE ((byte)43)
166 #define MLOG_COMP_LIST_START_DELETE ((byte)44)
168 #define MLOG_COMP_LIST_END_COPY_CREATED ((byte)45)
169 
173 #define MLOG_COMP_PAGE_REORGANIZE ((byte)46)
174 #define MLOG_FILE_CREATE2 ((byte)47)
176 #define MLOG_ZIP_WRITE_NODE_PTR ((byte)48)
179 #define MLOG_ZIP_WRITE_BLOB_PTR ((byte)49)
182 #define MLOG_ZIP_WRITE_HEADER ((byte)50)
184 #define MLOG_ZIP_PAGE_COMPRESS ((byte)51)
185 #define MLOG_ZIP_PAGE_COMPRESS_NO_DATA ((byte)52)
187 #define MLOG_ZIP_PAGE_REORGANIZE ((byte)53)
189 #define MLOG_BIGGEST_TYPE ((byte)53)
191 /* @} */
192 
196 #define MLOG_FILE_FLAG_TEMP 1
198 /* @} */
199 
200 /* included here because it needs MLOG_LSN defined */
201 #include "log0log.h"
202 
203 /***************************************************************/
205 UNIV_INLINE
206 void
207 mtr_start(
208 /*======*/
209  mtr_t* mtr)
210  __attribute__((nonnull));
211 /***************************************************************/
213 UNIV_INTERN
214 void
215 mtr_commit(
216 /*=======*/
217  mtr_t* mtr)
218  __attribute__((nonnull));
219 /**********************************************************/
222 UNIV_INLINE
223 ulint
225 /*==============*/
226  mtr_t* mtr);
227 #ifndef UNIV_HOTBACKUP
228 /**********************************************************/
231 UNIV_INLINE
232 void
234 /*=============================*/
235  mtr_t* mtr,
236  ulint savepoint,
237  rw_lock_t* lock);
238 #else /* !UNIV_HOTBACKUP */
239 # define mtr_release_s_latch_at_savepoint(mtr,savepoint,lock) ((void) 0)
240 #endif /* !UNIV_HOTBACKUP */
241 /***************************************************************/
244 UNIV_INLINE
245 ulint
247 /*=============*/
248  mtr_t* mtr);
249 /***************************************************************/
252 UNIV_INLINE
253 ulint
255 /*=============*/
256  mtr_t* mtr,
257  ulint mode);
258 /********************************************************/
261 UNIV_INTERN
262 ulint
264 /*===========*/
265  const byte* ptr,
266  ulint type,
267  mtr_t* mtr);
268 #ifndef UNIV_HOTBACKUP
269 /*********************************************************************/
271 #define mtr_s_lock(B, MTR) mtr_s_lock_func((B), __FILE__, __LINE__,\
272  (MTR))
273 /*********************************************************************/
275 #define mtr_x_lock(B, MTR) mtr_x_lock_func((B), __FILE__, __LINE__,\
276  (MTR))
277 /*********************************************************************/
280 UNIV_INLINE
281 void
283 /*============*/
284  rw_lock_t* lock,
285  const char* file,
286  ulint line,
287  mtr_t* mtr);
288 /*********************************************************************/
291 UNIV_INLINE
292 void
294 /*============*/
295  rw_lock_t* lock,
296  const char* file,
297  ulint line,
298  mtr_t* mtr);
299 #endif /* !UNIV_HOTBACKUP */
300 
301 /***************************************************/
304 UNIV_INTERN
305 bool
307 /*=============*/
308  mtr_t* mtr,
309  void* object,
310  ulint type)
311  __attribute__((nonnull));
312 #ifdef UNIV_DEBUG
313 # ifndef UNIV_HOTBACKUP
314 /**********************************************************/
317 UNIV_INLINE
318 bool
320 /*==============*/
321  mtr_t* mtr,
322  const void* object,
323  ulint type)
324  __attribute__((warn_unused_result, nonnull));
325 
326 /**********************************************************/
329 UNIV_INTERN
330 ibool
332 /*===================*/
333  mtr_t* mtr,
334  const byte* ptr,
335  ulint type);
336 /*********************************************************/
338 UNIV_INTERN
339 void
340 mtr_print(
341 /*======*/
342  mtr_t* mtr);
343 # else /* !UNIV_HOTBACKUP */
344 # define mtr_memo_contains(mtr, object, type) TRUE
345 # define mtr_memo_contains_page(mtr, ptr, type) TRUE
346 # endif /* !UNIV_HOTBACKUP */
347 #endif /* UNIV_DEBUG */
348 /*######################################################################*/
349 
350 #define MTR_BUF_MEMO_SIZE 200 /* number of slots in memo */
351 
352 /***************************************************************/
355 UNIV_INLINE
358 /*========*/
359  mtr_t* mtr);
360 /***************************************************/
362 UNIV_INLINE
363 void
365 /*==========*/
366  mtr_t* mtr,
367  void* object,
368  ulint type);
372  ulint type;
373  void* object;
374 };
376 /* Mini-transaction handle and buffer */
377 struct mtr_t{
378 #ifdef UNIV_DEBUG
379  ulint state;
380 #endif
381  dyn_array_t memo;
383  unsigned inside_ibuf:1;
385  unsigned modifications:1;
388  unsigned made_dirty:1;
391  ulint n_log_recs;
392  /* count of how many page initial log records
393  have been written to the mtr log */
394  ulint n_freed_pages;
395  /* number of pages that have been freed in
396  this mini-transaction */
397  ulint log_mode; /* specifies which operations should be
398  logged; default value MTR_LOG_ALL */
399  lsn_t start_lsn;/* start lsn of the possible log entry for
400  this mtr */
401  lsn_t end_lsn;/* end lsn of the possible log entry for
402  this mtr */
403 #ifdef UNIV_DEBUG
404  ulint magic_n;
405 #endif /* UNIV_DEBUG */
406 };
407 
408 #ifdef UNIV_DEBUG
409 # define MTR_MAGIC_N 54551
410 #endif /* UNIV_DEBUG */
411 
412 #define MTR_ACTIVE 12231
413 #define MTR_COMMITTING 56456
414 #define MTR_COMMITTED 34676
415 
416 #ifndef UNIV_NONINL
417 #include "mtr0mtr.ic"
418 #endif
419 
420 #endif