Drizzled Public API Documentation

mtr0mtr.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1995, 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 /**************************************************/
26 #pragma once
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_SPACE 23 */ /* log only operations modifying
44  file space page allocation data
45  (operations in fsp0fsp.* ) */
46 #define MTR_LOG_SHORT_INSERTS 24 /* inserts are logged in a shorter
47  form */
48 
49 /* Types for the mlock objects to store in the mtr memo; NOTE that the
50 first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
51 #define MTR_MEMO_PAGE_S_FIX RW_S_LATCH
52 #define MTR_MEMO_PAGE_X_FIX RW_X_LATCH
53 #define MTR_MEMO_BUF_FIX RW_NO_LATCH
54 #define MTR_MEMO_MODIFY 54
55 #define MTR_MEMO_S_LOCK 55
56 #define MTR_MEMO_X_LOCK 56
57 
62 #define MLOG_SINGLE_REC_FLAG 128
68 #define MLOG_1BYTE (1)
69 #define MLOG_2BYTES (2)
70 #define MLOG_4BYTES (4)
71 #define MLOG_8BYTES (8)
72 #define MLOG_REC_INSERT ((byte)9)
73 #define MLOG_REC_CLUST_DELETE_MARK ((byte)10)
75 #define MLOG_REC_SEC_DELETE_MARK ((byte)11)
77 #define MLOG_REC_UPDATE_IN_PLACE ((byte)13)
79 #define MLOG_REC_DELETE ((byte)14)
81 #define MLOG_LIST_END_DELETE ((byte)15)
83 #define MLOG_LIST_START_DELETE ((byte)16)
85 #define MLOG_LIST_END_COPY_CREATED ((byte)17)
87 #define MLOG_PAGE_REORGANIZE ((byte)18)
90 #define MLOG_PAGE_CREATE ((byte)19)
91 #define MLOG_UNDO_INSERT ((byte)20)
93 #define MLOG_UNDO_ERASE_END ((byte)21)
95 #define MLOG_UNDO_INIT ((byte)22)
97 #define MLOG_UNDO_HDR_DISCARD ((byte)23)
99 #define MLOG_UNDO_HDR_REUSE ((byte)24)
101 #define MLOG_UNDO_HDR_CREATE ((byte)25)
103 #define MLOG_REC_MIN_MARK ((byte)26)
107 #define MLOG_IBUF_BITMAP_INIT ((byte)27)
109 /*#define MLOG_FULL_PAGE ((byte)28) full contents of a page */
110 #ifdef UNIV_LOG_LSN_DEBUG
111 # define MLOG_LSN ((byte)28) /* current LSN */
112 #endif
113 #define MLOG_INIT_FILE_PAGE ((byte)29)
122 #define MLOG_WRITE_STRING ((byte)30)
124 #define MLOG_MULTI_REC_END ((byte)31)
128 #define MLOG_DUMMY_RECORD ((byte)32)
130 #define MLOG_FILE_CREATE ((byte)33)
132 #define MLOG_FILE_RENAME ((byte)34)
134 #define MLOG_FILE_DELETE ((byte)35)
136 #define MLOG_COMP_REC_MIN_MARK ((byte)36)
140 #define MLOG_COMP_PAGE_CREATE ((byte)37)
142 #define MLOG_COMP_REC_INSERT ((byte)38)
143 #define MLOG_COMP_REC_CLUST_DELETE_MARK ((byte)39)
144 
147 #define MLOG_COMP_REC_SEC_DELETE_MARK ((byte)40)
155 #define MLOG_COMP_REC_UPDATE_IN_PLACE ((byte)41)
159 #define MLOG_COMP_REC_DELETE ((byte)42)
161 #define MLOG_COMP_LIST_END_DELETE ((byte)43)
163 #define MLOG_COMP_LIST_START_DELETE ((byte)44)
165 #define MLOG_COMP_LIST_END_COPY_CREATED ((byte)45)
166 
170 #define MLOG_COMP_PAGE_REORGANIZE ((byte)46)
171 #define MLOG_FILE_CREATE2 ((byte)47)
173 #define MLOG_ZIP_WRITE_NODE_PTR ((byte)48)
176 #define MLOG_ZIP_WRITE_BLOB_PTR ((byte)49)
179 #define MLOG_ZIP_WRITE_HEADER ((byte)50)
181 #define MLOG_ZIP_PAGE_COMPRESS ((byte)51)
182 #define MLOG_BIGGEST_TYPE ((byte)51)
184 /* @} */
185 
189 #define MLOG_FILE_FLAG_TEMP 1
191 /* @} */
192 
193 /***************************************************************/
197 UNIV_INLINE
198 mtr_t*
199 mtr_start(
200 /*======*/
201  mtr_t* mtr);
202 /***************************************************************/
204 UNIV_INTERN
205 void
207 /*=======*/
208  mtr_t* mtr);
209 /**********************************************************/
212 UNIV_INLINE
213 ulint
215 /*==============*/
216  mtr_t* mtr);
217 /**********************************************************/
221 UNIV_INTERN
222 void
224 /*======================*/
225  mtr_t* mtr,
226  ulint savepoint);
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 /***************************************************/
303 UNIV_INTERN
304 void
306 /*=============*/
307  mtr_t* mtr,
308  void* object,
309  ulint type);
310 #ifdef UNIV_DEBUG
311 # ifndef UNIV_HOTBACKUP
312 /**********************************************************/
315 UNIV_INLINE
316 ibool
317 mtr_memo_contains(
318 /*==============*/
319  mtr_t* mtr,
320  const void* object,
321  ulint type);
323 /**********************************************************/
326 UNIV_INTERN
327 ibool
328 mtr_memo_contains_page(
329 /*===================*/
330  mtr_t* mtr,
331  const byte* ptr,
332  ulint type);
333 /*********************************************************/
335 UNIV_INTERN
336 void
337 mtr_print(
338 /*======*/
339  mtr_t* mtr);
340 # else /* !UNIV_HOTBACKUP */
341 # define mtr_memo_contains(mtr, object, type) TRUE
342 # define mtr_memo_contains_page(mtr, ptr, type) TRUE
343 # endif /* !UNIV_HOTBACKUP */
344 #endif /* UNIV_DEBUG */
345 /*######################################################################*/
346 
347 #define MTR_BUF_MEMO_SIZE 200 /* number of slots in memo */
348 
349 /***************************************************************/
352 UNIV_INLINE
355 /*========*/
356  mtr_t* mtr);
357 /***************************************************/
359 UNIV_INLINE
360 void
362 /*==========*/
363  mtr_t* mtr,
364  void* object,
365  ulint type);
368 /* Type definition of a mini-transaction memo stack slot. */
370 struct mtr_memo_slot_struct{
371  ulint type;
372  void* object;
373 };
374 
375 /* Mini-transaction handle and buffer */
376 struct mtr_struct{
377 #ifdef UNIV_DEBUG
378  ulint state;
379 #endif
380  dyn_array_t memo;
381  dyn_array_t log;
382  ibool modifications;
383  /* TRUE if the mtr made modifications to
384  buffer pool pages */
385  ulint n_log_recs;
386  /* count of how many page initial log records
387  have been written to the mtr log */
388  ulint log_mode; /* specifies which operations should be
389  logged; default value MTR_LOG_ALL */
390  ib_uint64_t start_lsn;/* start lsn of the possible log entry for
391  this mtr */
392  ib_uint64_t end_lsn;/* end lsn of the possible log entry for
393  this mtr */
394 #ifdef UNIV_DEBUG
395  ulint magic_n;
396 #endif /* UNIV_DEBUG */
397 };
398 
399 #ifdef UNIV_DEBUG
400 # define MTR_MAGIC_N 54551
401 #endif /* UNIV_DEBUG */
402 
403 #define MTR_ACTIVE 12231
404 #define MTR_COMMITTING 56456
405 #define MTR_COMMITTED 34676
406 
407 #ifndef UNIV_NONINL
408 #include "mtr0mtr.ic"
409 #endif
410 
411 #endif