Drizzled Public API Documentation

mtr0mtr.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef mtr0mtr_h
00028 #define mtr0mtr_h
00029 
00030 #include "univ.i"
00031 #include "mem0mem.h"
00032 #include "dyn0dyn.h"
00033 #include "buf0types.h"
00034 #include "sync0rw.h"
00035 #include "ut0byte.h"
00036 #include "mtr0types.h"
00037 #include "page0types.h"
00038 
00039 /* Logging modes for a mini-transaction */
00040 #define MTR_LOG_ALL   21  /* default mode: log all operations
00041           modifying disk-based data */
00042 #define MTR_LOG_NONE    22  /* log no operations */
00043 /*#define MTR_LOG_SPACE 23 */ /* log only operations modifying
00044           file space page allocation data
00045           (operations in fsp0fsp.* ) */
00046 #define MTR_LOG_SHORT_INSERTS 24  /* inserts are logged in a shorter
00047           form */
00048 
00049 /* Types for the mlock objects to store in the mtr memo; NOTE that the
00050 first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
00051 #define MTR_MEMO_PAGE_S_FIX RW_S_LATCH
00052 #define MTR_MEMO_PAGE_X_FIX RW_X_LATCH
00053 #define MTR_MEMO_BUF_FIX  RW_NO_LATCH
00054 #define MTR_MEMO_MODIFY   54
00055 #define MTR_MEMO_S_LOCK   55
00056 #define MTR_MEMO_X_LOCK   56
00057 
00062 #define MLOG_SINGLE_REC_FLAG  128   
00068 #define MLOG_1BYTE    (1)   
00069 #define MLOG_2BYTES   (2)   
00070 #define MLOG_4BYTES   (4)   
00071 #define MLOG_8BYTES   (8)   
00072 #define MLOG_REC_INSERT   ((byte)9) 
00073 #define MLOG_REC_CLUST_DELETE_MARK ((byte)10) 
00075 #define MLOG_REC_SEC_DELETE_MARK ((byte)11) 
00077 #define MLOG_REC_UPDATE_IN_PLACE ((byte)13) 
00079 #define MLOG_REC_DELETE   ((byte)14)  
00081 #define MLOG_LIST_END_DELETE  ((byte)15)  
00083 #define MLOG_LIST_START_DELETE  ((byte)16)  
00085 #define MLOG_LIST_END_COPY_CREATED ((byte)17) 
00087 #define MLOG_PAGE_REORGANIZE  ((byte)18)  
00090 #define MLOG_PAGE_CREATE  ((byte)19)  
00091 #define MLOG_UNDO_INSERT  ((byte)20)  
00093 #define MLOG_UNDO_ERASE_END ((byte)21)  
00095 #define MLOG_UNDO_INIT    ((byte)22)  
00097 #define MLOG_UNDO_HDR_DISCARD ((byte)23)  
00099 #define MLOG_UNDO_HDR_REUSE ((byte)24)  
00101 #define MLOG_UNDO_HDR_CREATE  ((byte)25)  
00103 #define MLOG_REC_MIN_MARK ((byte)26)  
00107 #define MLOG_IBUF_BITMAP_INIT ((byte)27)  
00109 /*#define MLOG_FULL_PAGE  ((byte)28)  full contents of a page */
00110 #ifdef UNIV_LOG_LSN_DEBUG
00111 # define MLOG_LSN   ((byte)28)  /* current LSN */
00112 #endif
00113 #define MLOG_INIT_FILE_PAGE ((byte)29)  
00122 #define MLOG_WRITE_STRING ((byte)30)  
00124 #define MLOG_MULTI_REC_END  ((byte)31)  
00128 #define MLOG_DUMMY_RECORD ((byte)32)  
00130 #define MLOG_FILE_CREATE  ((byte)33)  
00132 #define MLOG_FILE_RENAME  ((byte)34)  
00134 #define MLOG_FILE_DELETE  ((byte)35)  
00136 #define MLOG_COMP_REC_MIN_MARK  ((byte)36)  
00140 #define MLOG_COMP_PAGE_CREATE ((byte)37)  
00142 #define MLOG_COMP_REC_INSERT  ((byte)38)  
00143 #define MLOG_COMP_REC_CLUST_DELETE_MARK ((byte)39)
00144 
00147 #define MLOG_COMP_REC_SEC_DELETE_MARK ((byte)40)
00155 #define MLOG_COMP_REC_UPDATE_IN_PLACE ((byte)41)
00159 #define MLOG_COMP_REC_DELETE  ((byte)42)  
00161 #define MLOG_COMP_LIST_END_DELETE ((byte)43)  
00163 #define MLOG_COMP_LIST_START_DELETE ((byte)44)  
00165 #define MLOG_COMP_LIST_END_COPY_CREATED ((byte)45)
00166 
00170 #define MLOG_COMP_PAGE_REORGANIZE ((byte)46)  
00171 #define MLOG_FILE_CREATE2 ((byte)47)  
00173 #define MLOG_ZIP_WRITE_NODE_PTR ((byte)48)  
00176 #define MLOG_ZIP_WRITE_BLOB_PTR ((byte)49)  
00179 #define MLOG_ZIP_WRITE_HEADER ((byte)50)  
00181 #define MLOG_ZIP_PAGE_COMPRESS  ((byte)51)  
00182 #define MLOG_BIGGEST_TYPE ((byte)51)  
00184 /* @} */
00185 
00189 #define MLOG_FILE_FLAG_TEMP 1 
00191 /* @} */
00192 
00193 /***************************************************************/
00197 UNIV_INLINE
00198 mtr_t*
00199 mtr_start(
00200 /*======*/
00201   mtr_t*  mtr); 
00202 /***************************************************************/
00204 UNIV_INTERN
00205 void
00206 mtr_commit(
00207 /*=======*/
00208   mtr_t*  mtr); 
00209 /**********************************************************/
00212 UNIV_INLINE
00213 ulint
00214 mtr_set_savepoint(
00215 /*==============*/
00216   mtr_t*  mtr); 
00217 /**********************************************************/
00221 UNIV_INTERN
00222 void
00223 mtr_rollback_to_savepoint(
00224 /*======================*/
00225   mtr_t*  mtr,    
00226   ulint savepoint); 
00227 #ifndef UNIV_HOTBACKUP
00228 /**********************************************************/
00231 UNIV_INLINE
00232 void
00233 mtr_release_s_latch_at_savepoint(
00234 /*=============================*/
00235   mtr_t*    mtr,    
00236   ulint   savepoint,  
00237   rw_lock_t*  lock);    
00238 #else /* !UNIV_HOTBACKUP */
00239 # define mtr_release_s_latch_at_savepoint(mtr,savepoint,lock) ((void) 0)
00240 #endif /* !UNIV_HOTBACKUP */
00241 /***************************************************************/
00244 UNIV_INLINE
00245 ulint
00246 mtr_get_log_mode(
00247 /*=============*/
00248   mtr_t*  mtr); 
00249 /***************************************************************/
00252 UNIV_INLINE
00253 ulint
00254 mtr_set_log_mode(
00255 /*=============*/
00256   mtr_t*  mtr,  
00257   ulint mode);  
00258 /********************************************************/
00261 UNIV_INTERN
00262 ulint
00263 mtr_read_ulint(
00264 /*===========*/
00265   const byte* ptr,  
00266   ulint   type, 
00267   mtr_t*    mtr); 
00268 #ifndef UNIV_HOTBACKUP
00269 /*********************************************************************/
00271 #define mtr_s_lock(B, MTR)  mtr_s_lock_func((B), __FILE__, __LINE__,\
00272             (MTR))
00273 /*********************************************************************/
00275 #define mtr_x_lock(B, MTR)  mtr_x_lock_func((B), __FILE__, __LINE__,\
00276             (MTR))
00277 /*********************************************************************/
00280 UNIV_INLINE
00281 void
00282 mtr_s_lock_func(
00283 /*============*/
00284   rw_lock_t*  lock, 
00285   const char* file, 
00286   ulint   line, 
00287   mtr_t*    mtr); 
00288 /*********************************************************************/
00291 UNIV_INLINE
00292 void
00293 mtr_x_lock_func(
00294 /*============*/
00295   rw_lock_t*  lock, 
00296   const char* file, 
00297   ulint   line, 
00298   mtr_t*    mtr); 
00299 #endif /* !UNIV_HOTBACKUP */
00300 
00301 /***************************************************/
00303 UNIV_INTERN
00304 void
00305 mtr_memo_release(
00306 /*=============*/
00307   mtr_t*  mtr,  
00308   void* object, 
00309   ulint type);  
00310 #ifdef UNIV_DEBUG
00311 # ifndef UNIV_HOTBACKUP
00312 /**********************************************************/
00315 UNIV_INLINE
00316 ibool
00317 mtr_memo_contains(
00318 /*==============*/
00319   mtr_t*    mtr,  
00320   const void* object, 
00321   ulint   type);  
00323 /**********************************************************/
00326 UNIV_INTERN
00327 ibool
00328 mtr_memo_contains_page(
00329 /*===================*/
00330   mtr_t*    mtr,  
00331   const byte* ptr,  
00332   ulint   type);  
00333 /*********************************************************/
00335 UNIV_INTERN
00336 void
00337 mtr_print(
00338 /*======*/
00339   mtr_t*  mtr); 
00340 # else /* !UNIV_HOTBACKUP */
00341 #  define mtr_memo_contains(mtr, object, type)    TRUE
00342 #  define mtr_memo_contains_page(mtr, ptr, type)  TRUE
00343 # endif /* !UNIV_HOTBACKUP */
00344 #endif /* UNIV_DEBUG */
00345 /*######################################################################*/
00346 
00347 #define MTR_BUF_MEMO_SIZE 200 /* number of slots in memo */
00348 
00349 /***************************************************************/
00352 UNIV_INLINE
00353 dyn_array_t*
00354 mtr_get_log(
00355 /*========*/
00356   mtr_t*  mtr); 
00357 /***************************************************/
00359 UNIV_INLINE
00360 void
00361 mtr_memo_push(
00362 /*==========*/
00363   mtr_t*  mtr,  
00364   void* object, 
00365   ulint type);  
00368 /* Type definition of a mini-transaction memo stack slot. */
00369 typedef struct mtr_memo_slot_struct mtr_memo_slot_t;
00370 struct mtr_memo_slot_struct{
00371   ulint type; 
00372   void* object; 
00373 };
00374 
00375 /* Mini-transaction handle and buffer */
00376 struct mtr_struct{
00377 #ifdef UNIV_DEBUG
00378   ulint   state;  
00379 #endif
00380   dyn_array_t memo; 
00381   dyn_array_t log;  
00382   ibool   modifications;
00383         /* TRUE if the mtr made modifications to
00384         buffer pool pages */
00385   ulint   n_log_recs;
00386         /* count of how many page initial log records
00387         have been written to the mtr log */
00388   ulint   log_mode; /* specifies which operations should be
00389         logged; default value MTR_LOG_ALL */
00390   ib_uint64_t start_lsn;/* start lsn of the possible log entry for
00391         this mtr */
00392   ib_uint64_t end_lsn;/* end lsn of the possible log entry for
00393         this mtr */
00394 #ifdef UNIV_DEBUG
00395   ulint   magic_n;
00396 #endif /* UNIV_DEBUG */
00397 };
00398 
00399 #ifdef UNIV_DEBUG
00400 # define MTR_MAGIC_N    54551
00401 #endif /* UNIV_DEBUG */
00402 
00403 #define MTR_ACTIVE    12231
00404 #define MTR_COMMITTING    56456
00405 #define MTR_COMMITTED   34676
00406 
00407 #ifndef UNIV_NONINL
00408 #include "mtr0mtr.ic"
00409 #endif
00410 
00411 #endif