00001 /***************************************************************************** 00002 00003 Copyright (C) 1996, 2010, 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 trx0rseg_h 00028 #define trx0rseg_h 00029 00030 #include "univ.i" 00031 #include "trx0types.h" 00032 #include "trx0sys.h" 00033 00034 /******************************************************************/ 00037 UNIV_INLINE 00038 trx_rsegf_t* 00039 trx_rsegf_get( 00040 /*==========*/ 00041 ulint space, 00042 ulint zip_size, 00044 ulint page_no, 00045 mtr_t* mtr); 00046 /******************************************************************/ 00049 UNIV_INLINE 00050 trx_rsegf_t* 00051 trx_rsegf_get_new( 00052 /*==============*/ 00053 ulint space, 00054 ulint zip_size, 00056 ulint page_no, 00057 mtr_t* mtr); 00058 /***************************************************************/ 00061 UNIV_INLINE 00062 ulint 00063 trx_rsegf_get_nth_undo( 00064 /*===================*/ 00065 trx_rsegf_t* rsegf, 00066 ulint n, 00067 mtr_t* mtr); 00068 /***************************************************************/ 00070 UNIV_INLINE 00071 void 00072 trx_rsegf_set_nth_undo( 00073 /*===================*/ 00074 trx_rsegf_t* rsegf, 00075 ulint n, 00076 ulint page_no, 00077 mtr_t* mtr); 00078 /****************************************************************/ 00081 UNIV_INLINE 00082 ulint 00083 trx_rsegf_undo_find_free( 00084 /*=====================*/ 00085 trx_rsegf_t* rsegf, 00086 mtr_t* mtr); 00087 /******************************************************************/ 00090 UNIV_INTERN 00091 trx_rseg_t* 00092 trx_rseg_get_on_id( 00093 /*===============*/ 00094 ulint id); 00095 /****************************************************************/ 00099 UNIV_INTERN 00100 ulint 00101 trx_rseg_header_create( 00102 /*===================*/ 00103 ulint space, 00104 ulint zip_size, 00106 ulint max_size, 00107 ulint rseg_slot_no, 00108 mtr_t* mtr); 00109 /*********************************************************************/ 00112 UNIV_INTERN 00113 void 00114 trx_rseg_list_and_array_init( 00115 /*=========================*/ 00116 trx_sysf_t* sys_header, 00117 mtr_t* mtr); 00118 /*************************************************************************** 00119 Free's an instance of the rollback segment in memory. */ 00120 UNIV_INTERN 00121 void 00122 trx_rseg_mem_free( 00123 /*==============*/ 00124 trx_rseg_t* rseg); /* in, own: instance to free */ 00125 00126 /********************************************************************* 00127 Creates a rollback segment. */ 00128 UNIV_INTERN 00129 trx_rseg_t* 00130 trx_rseg_create(void); 00131 /*==================*/ 00132 00133 /* Number of undo log slots in a rollback segment file copy */ 00134 #define TRX_RSEG_N_SLOTS (UNIV_PAGE_SIZE / 16) 00135 00136 /* Maximum number of transactions supported by a single rollback segment */ 00137 #define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) 00138 00139 /* The rollback segment memory object */ 00140 struct trx_rseg_struct{ 00141 /*--------------------------------------------------------*/ 00142 ulint id; 00144 mutex_t mutex; 00148 ulint space; 00150 ulint zip_size;/* compressed page size of space 00151 in bytes, or 0 for uncompressed spaces */ 00152 ulint page_no;/* page number of the rollback segment 00153 header */ 00154 ulint max_size;/* maximum allowed size in pages */ 00155 ulint curr_size;/* current size in pages */ 00156 /*--------------------------------------------------------*/ 00157 /* Fields for update undo logs */ 00158 UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list; 00159 /* List of update undo logs */ 00160 UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_cached; 00161 /* List of update undo log segments 00162 cached for fast reuse */ 00163 /*--------------------------------------------------------*/ 00164 /* Fields for insert undo logs */ 00165 UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list; 00166 /* List of insert undo logs */ 00167 UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached; 00168 /* List of insert undo log segments 00169 cached for fast reuse */ 00170 /*--------------------------------------------------------*/ 00171 ulint last_page_no; 00174 ulint last_offset; 00176 trx_id_t last_trx_no; 00178 ibool last_del_marks; 00180 /*--------------------------------------------------------*/ 00181 UT_LIST_NODE_T(trx_rseg_t) rseg_list; 00182 /* the list of the rollback segment 00183 memory objects */ 00184 }; 00185 00186 /* Undo log segment slot in a rollback segment header */ 00187 /*-------------------------------------------------------------*/ 00188 #define TRX_RSEG_SLOT_PAGE_NO 0 /* Page number of the header page of 00189 an undo log segment */ 00190 /*-------------------------------------------------------------*/ 00191 /* Slot size */ 00192 #define TRX_RSEG_SLOT_SIZE 4 00193 00194 /* The offset of the rollback segment header on its page */ 00195 #define TRX_RSEG FSEG_PAGE_DATA 00196 00197 /* Transaction rollback segment header */ 00198 /*-------------------------------------------------------------*/ 00199 #define TRX_RSEG_MAX_SIZE 0 /* Maximum allowed size for rollback 00200 segment in pages */ 00201 #define TRX_RSEG_HISTORY_SIZE 4 /* Number of file pages occupied 00202 by the logs in the history list */ 00203 #define TRX_RSEG_HISTORY 8 /* The update undo logs for committed 00204 transactions */ 00205 #define TRX_RSEG_FSEG_HEADER (8 + FLST_BASE_NODE_SIZE) 00206 /* Header for the file segment where 00207 this page is placed */ 00208 #define TRX_RSEG_UNDO_SLOTS (8 + FLST_BASE_NODE_SIZE + FSEG_HEADER_SIZE) 00209 /* Undo log segment slots */ 00210 /*-------------------------------------------------------------*/ 00211 00212 #ifndef UNIV_NONINL 00213 #include "trx0rseg.ic" 00214 #endif 00215 00216 #endif