00001 /****************************************************** 00002 Mini-transaction logging routines 00003 00004 (c) 1995 Innobase Oy 00005 00006 Created 12/7/1995 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef mtr0log_h 00010 #define mtr0log_h 00011 00012 #include "univ.i" 00013 #include "mtr0mtr.h" 00014 #include "dict0types.h" 00015 00016 /************************************************************ 00017 Writes 1 - 4 bytes to a file page buffered in the buffer pool. 00018 Writes the corresponding log record to the mini-transaction log. */ 00019 00020 void 00021 mlog_write_ulint( 00022 /*=============*/ 00023 byte* ptr, /* in: pointer where to write */ 00024 ulint val, /* in: value to write */ 00025 byte type, /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ 00026 mtr_t* mtr); /* in: mini-transaction handle */ 00027 /************************************************************ 00028 Writes 8 bytes to a file page buffered in the buffer pool. 00029 Writes the corresponding log record to the mini-transaction log. */ 00030 00031 void 00032 mlog_write_dulint( 00033 /*==============*/ 00034 byte* ptr, /* in: pointer where to write */ 00035 dulint val, /* in: value to write */ 00036 mtr_t* mtr); /* in: mini-transaction handle */ 00037 /************************************************************ 00038 Writes a string to a file page buffered in the buffer pool. Writes the 00039 corresponding log record to the mini-transaction log. */ 00040 00041 void 00042 mlog_write_string( 00043 /*==============*/ 00044 byte* ptr, /* in: pointer where to write */ 00045 const byte* str, /* in: string to write */ 00046 ulint len, /* in: string length */ 00047 mtr_t* mtr); /* in: mini-transaction handle */ 00048 /************************************************************ 00049 Writes initial part of a log record consisting of one-byte item 00050 type and four-byte space and page numbers. */ 00051 00052 void 00053 mlog_write_initial_log_record( 00054 /*==========================*/ 00055 byte* ptr, /* in: pointer to (inside) a buffer frame 00056 holding the file page where modification 00057 is made */ 00058 byte type, /* in: log item type: MLOG_1BYTE, ... */ 00059 mtr_t* mtr); /* in: mini-transaction handle */ 00060 /************************************************************ 00061 Writes a log record about an .ibd file create/delete/rename. */ 00062 UNIV_INLINE 00063 byte* 00064 mlog_write_initial_log_record_for_file_op( 00065 /*======================================*/ 00066 /* out: new value of log_ptr */ 00067 ulint type, /* in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or 00068 MLOG_FILE_RENAME */ 00069 ulint space_id,/* in: space id, if applicable */ 00070 ulint page_no,/* in: page number (not relevant currently) */ 00071 byte* log_ptr,/* in: pointer to mtr log which has been opened */ 00072 mtr_t* mtr); /* in: mtr */ 00073 /************************************************************ 00074 Catenates 1 - 4 bytes to the mtr log. */ 00075 UNIV_INLINE 00076 void 00077 mlog_catenate_ulint( 00078 /*================*/ 00079 mtr_t* mtr, /* in: mtr */ 00080 ulint val, /* in: value to write */ 00081 ulint type); /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ 00082 /************************************************************ 00083 Catenates n bytes to the mtr log. */ 00084 00085 void 00086 mlog_catenate_string( 00087 /*=================*/ 00088 mtr_t* mtr, /* in: mtr */ 00089 const byte* str, /* in: string to write */ 00090 ulint len); /* in: string length */ 00091 /************************************************************ 00092 Catenates a compressed ulint to mlog. */ 00093 UNIV_INLINE 00094 void 00095 mlog_catenate_ulint_compressed( 00096 /*===========================*/ 00097 mtr_t* mtr, /* in: mtr */ 00098 ulint val); /* in: value to write */ 00099 /************************************************************ 00100 Catenates a compressed dulint to mlog. */ 00101 UNIV_INLINE 00102 void 00103 mlog_catenate_dulint_compressed( 00104 /*============================*/ 00105 mtr_t* mtr, /* in: mtr */ 00106 dulint val); /* in: value to write */ 00107 /************************************************************ 00108 Opens a buffer to mlog. It must be closed with mlog_close. */ 00109 UNIV_INLINE 00110 byte* 00111 mlog_open( 00112 /*======*/ 00113 /* out: buffer, NULL if log mode MTR_LOG_NONE */ 00114 mtr_t* mtr, /* in: mtr */ 00115 ulint size); /* in: buffer size in bytes; MUST be 00116 smaller than DYN_ARRAY_DATA_SIZE! */ 00117 /************************************************************ 00118 Closes a buffer opened to mlog. */ 00119 UNIV_INLINE 00120 void 00121 mlog_close( 00122 /*=======*/ 00123 mtr_t* mtr, /* in: mtr */ 00124 byte* ptr); /* in: buffer space from ptr up was not used */ 00125 /************************************************************ 00126 Writes the initial part of a log record (3..11 bytes). 00127 If the implementation of this function is changed, all 00128 size parameters to mlog_open() should be adjusted accordingly! */ 00129 UNIV_INLINE 00130 byte* 00131 mlog_write_initial_log_record_fast( 00132 /*===============================*/ 00133 /* out: new value of log_ptr */ 00134 byte* ptr, /* in: pointer to (inside) a buffer frame holding the 00135 file page where modification is made */ 00136 byte type, /* in: log item type: MLOG_1BYTE, ... */ 00137 byte* log_ptr,/* in: pointer to mtr log which has been opened */ 00138 mtr_t* mtr); /* in: mtr */ 00139 /************************************************************ 00140 Parses an initial log record written by mlog_write_initial_log_record. */ 00141 00142 byte* 00143 mlog_parse_initial_log_record( 00144 /*==========================*/ 00145 /* out: parsed record end, NULL if not a complete 00146 record */ 00147 byte* ptr, /* in: buffer */ 00148 byte* end_ptr,/* in: buffer end */ 00149 byte* type, /* out: log record type: MLOG_1BYTE, ... */ 00150 ulint* space, /* out: space id */ 00151 ulint* page_no);/* out: page number */ 00152 /************************************************************ 00153 Parses a log record written by mlog_write_ulint or mlog_write_dulint. */ 00154 00155 byte* 00156 mlog_parse_nbytes( 00157 /*==============*/ 00158 /* out: parsed record end, NULL if not a complete 00159 record */ 00160 ulint type, /* in: log record type: MLOG_1BYTE, ... */ 00161 byte* ptr, /* in: buffer */ 00162 byte* end_ptr,/* in: buffer end */ 00163 byte* page); /* in: page where to apply the log record, or NULL */ 00164 /************************************************************ 00165 Parses a log record written by mlog_write_string. */ 00166 00167 byte* 00168 mlog_parse_string( 00169 /*==============*/ 00170 /* out: parsed record end, NULL if not a complete 00171 record */ 00172 byte* ptr, /* in: buffer */ 00173 byte* end_ptr,/* in: buffer end */ 00174 byte* page); /* in: page where to apply the log record, or NULL */ 00175 00176 00177 /************************************************************ 00178 Opens a buffer for mlog, writes the initial log record and, 00179 if needed, the field lengths of an index. Reserves space 00180 for further log entries. The log entry must be closed with 00181 mtr_close(). */ 00182 00183 byte* 00184 mlog_open_and_write_index( 00185 /*======================*/ 00186 /* out: buffer, NULL if log mode 00187 MTR_LOG_NONE */ 00188 mtr_t* mtr, /* in: mtr */ 00189 byte* rec, /* in: index record or page */ 00190 dict_index_t* index, /* in: record descriptor */ 00191 byte type, /* in: log item type */ 00192 ulint size); /* in: requested buffer size in bytes 00193 (if 0, calls mlog_close() and returns NULL) */ 00194 00195 /************************************************************ 00196 Parses a log record written by mlog_open_and_write_index. */ 00197 00198 byte* 00199 mlog_parse_index( 00200 /*=============*/ 00201 /* out: parsed record end, 00202 NULL if not a complete record */ 00203 byte* ptr, /* in: buffer */ 00204 byte* end_ptr,/* in: buffer end */ 00205 /* out: new value of log_ptr */ 00206 ibool comp, /* in: TRUE=compact record format */ 00207 dict_index_t** index); /* out, own: dummy index */ 00208 00209 /* Insert, update, and maybe other functions may use this value to define an 00210 extra mlog buffer size for variable size data */ 00211 #define MLOG_BUF_MARGIN 256 00212 00213 #ifndef UNIV_NONINL 00214 #include "mtr0log.ic" 00215 #endif 00216 00217 #endif
1.4.7

