00001 /***************************************************************************** 00002 00003 Copyright (C) 1996, 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 trx0purge_h 00028 #define trx0purge_h 00029 00030 #include "univ.i" 00031 #include "trx0types.h" 00032 #include "mtr0mtr.h" 00033 #include "trx0sys.h" 00034 #include "que0types.h" 00035 #include "page0page.h" 00036 #include "usr0sess.h" 00037 #include "fil0fil.h" 00038 00040 extern trx_purge_t* purge_sys; 00041 00044 extern trx_undo_rec_t trx_purge_dummy_rec; 00045 00046 /********************************************************************/ 00050 UNIV_INLINE 00051 fil_addr_t 00052 trx_purge_get_log_from_hist( 00053 /*========================*/ 00054 fil_addr_t node_addr); 00056 /*****************************************************************/ 00062 UNIV_INTERN 00063 ibool 00064 trx_purge_update_undo_must_exist( 00065 /*=============================*/ 00066 trx_id_t trx_id); 00067 /********************************************************************/ 00070 UNIV_INTERN 00071 void 00072 trx_purge_sys_create(void); 00073 /*======================*/ 00074 /********************************************************************/ 00076 UNIV_INTERN 00077 void 00078 trx_purge_sys_close(void); 00079 /*======================*/ 00080 /************************************************************************ 00081 Adds the update undo log as the first log in the history list. Removes the 00082 update undo log segment from the rseg slot if it is too big for reuse. */ 00083 UNIV_INTERN 00084 void 00085 trx_purge_add_update_undo_to_history( 00086 /*=================================*/ 00087 trx_t* trx, 00088 page_t* undo_page, 00090 mtr_t* mtr); 00091 /********************************************************************/ 00096 UNIV_INTERN 00097 trx_undo_rec_t* 00098 trx_purge_fetch_next_rec( 00099 /*=====================*/ 00100 roll_ptr_t* roll_ptr, 00101 trx_undo_inf_t** cell, 00103 mem_heap_t* heap); 00104 /*******************************************************************/ 00106 UNIV_INTERN 00107 void 00108 trx_purge_rec_release( 00109 /*==================*/ 00110 trx_undo_inf_t* cell); 00111 /*******************************************************************/ 00114 UNIV_INTERN 00115 ulint 00116 trx_purge( 00117 /*======*/ 00118 ulint limit); 00120 /******************************************************************/ 00122 UNIV_INTERN 00123 void 00124 trx_purge_sys_print(void); 00125 /*======================*/ 00126 00128 struct trx_purge_struct{ 00129 ulint state; 00130 sess_t* sess; 00132 trx_t* trx; 00135 que_t* query; 00137 rw_lock_t latch; 00143 read_view_t* view; 00145 mutex_t mutex; 00146 ulint n_pages_handled; 00148 ulint handle_limit; 00150 /*------------------------------*/ 00151 /* The following two fields form the 'purge pointer' which advances 00152 during a purge, and which is used in history list truncation */ 00153 00154 trx_id_t purge_trx_no; 00157 undo_no_t purge_undo_no; 00159 /*-----------------------------*/ 00160 ibool next_stored; 00165 trx_rseg_t* rseg; 00167 ulint page_no; 00170 ulint offset; 00173 ulint hdr_page_no; 00175 ulint hdr_offset; 00176 /*-----------------------------*/ 00177 trx_undo_arr_t* arr; 00180 mem_heap_t* heap; 00183 }; 00184 00185 #define TRX_PURGE_ON 1 /* purge operation is running */ 00186 #define TRX_STOP_PURGE 2 /* purge operation is stopped, or 00187 it should be stopped */ 00188 #ifndef UNIV_NONINL 00189 #include "trx0purge.ic" 00190 #endif 00191 00192 #endif