1
by brian
clean slate |
1 |
/******************************************************
|
2 |
Mini-transaction logging routines
|
|
3 |
||
4 |
(c) 1995 Innobase Oy
|
|
5 |
||
6 |
Created 12/7/1995 Heikki Tuuri
|
|
7 |
*******************************************************/
|
|
8 |
||
9 |
#ifndef mtr0log_h
|
|
10 |
#define mtr0log_h
|
|
11 |
||
12 |
#include "univ.i" |
|
13 |
#include "mtr0mtr.h" |
|
14 |
#include "dict0types.h" |
|
15 |
||
16 |
/************************************************************
|
|
17 |
Writes 1 - 4 bytes to a file page buffered in the buffer pool.
|
|
18 |
Writes the corresponding log record to the mini-transaction log. */
|
|
19 |
||
20 |
void
|
|
21 |
mlog_write_ulint( |
|
22 |
/*=============*/
|
|
23 |
byte* ptr, /* in: pointer where to write */ |
|
24 |
ulint val, /* in: value to write */ |
|
25 |
byte type, /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ |
|
26 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
27 |
/************************************************************
|
|
28 |
Writes 8 bytes to a file page buffered in the buffer pool.
|
|
29 |
Writes the corresponding log record to the mini-transaction log. */
|
|
30 |
||
31 |
void
|
|
32 |
mlog_write_dulint( |
|
33 |
/*==============*/
|
|
34 |
byte* ptr, /* in: pointer where to write */ |
|
35 |
dulint val, /* in: value to write */ |
|
36 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
37 |
/************************************************************
|
|
38 |
Writes a string to a file page buffered in the buffer pool. Writes the
|
|
39 |
corresponding log record to the mini-transaction log. */
|
|
40 |
||
41 |
void
|
|
42 |
mlog_write_string( |
|
43 |
/*==============*/
|
|
44 |
byte* ptr, /* in: pointer where to write */ |
|
45 |
const byte* str, /* in: string to write */ |
|
46 |
ulint len, /* in: string length */ |
|
47 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
48 |
/************************************************************
|
|
49 |
Writes initial part of a log record consisting of one-byte item
|
|
50 |
type and four-byte space and page numbers. */
|
|
51 |
||
52 |
void
|
|
53 |
mlog_write_initial_log_record( |
|
54 |
/*==========================*/
|
|
55 |
byte* ptr, /* in: pointer to (inside) a buffer frame |
|
56 |
holding the file page where modification |
|
57 |
is made */ |
|
58 |
byte type, /* in: log item type: MLOG_1BYTE, ... */ |
|
59 |
mtr_t* mtr); /* in: mini-transaction handle */ |
|
60 |
/************************************************************
|
|
61 |
Writes a log record about an .ibd file create/delete/rename. */
|
|
62 |
UNIV_INLINE
|
|
63 |
byte* |
|
64 |
mlog_write_initial_log_record_for_file_op( |
|
65 |
/*======================================*/
|
|
66 |
/* out: new value of log_ptr */
|
|
67 |
ulint type, /* in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or |
|
68 |
MLOG_FILE_RENAME */
|
|
69 |
ulint space_id,/* in: space id, if applicable */ |
|
70 |
ulint page_no,/* in: page number (not relevant currently) */ |
|
71 |
byte* log_ptr,/* in: pointer to mtr log which has been opened */ |
|
72 |
mtr_t* mtr); /* in: mtr */ |
|
73 |
/************************************************************
|
|
74 |
Catenates 1 - 4 bytes to the mtr log. */
|
|
75 |
UNIV_INLINE
|
|
76 |
void
|
|
77 |
mlog_catenate_ulint( |
|
78 |
/*================*/
|
|
79 |
mtr_t* mtr, /* in: mtr */ |
|
80 |
ulint val, /* in: value to write */ |
|
81 |
ulint type); /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ |
|
82 |
/************************************************************
|
|
83 |
Catenates n bytes to the mtr log. */
|
|
84 |
||
85 |
void
|
|
86 |
mlog_catenate_string( |
|
87 |
/*=================*/
|
|
88 |
mtr_t* mtr, /* in: mtr */ |
|
89 |
const byte* str, /* in: string to write */ |
|
90 |
ulint len); /* in: string length */ |
|
91 |
/************************************************************
|
|
92 |
Catenates a compressed ulint to mlog. */
|
|
93 |
UNIV_INLINE
|
|
94 |
void
|
|
95 |
mlog_catenate_ulint_compressed( |
|
96 |
/*===========================*/
|
|
97 |
mtr_t* mtr, /* in: mtr */ |
|
98 |
ulint val); /* in: value to write */ |
|
99 |
/************************************************************
|
|
100 |
Catenates a compressed dulint to mlog. */
|
|
101 |
UNIV_INLINE
|
|
102 |
void
|
|
103 |
mlog_catenate_dulint_compressed( |
|
104 |
/*============================*/
|
|
105 |
mtr_t* mtr, /* in: mtr */ |
|
106 |
dulint val); /* in: value to write */ |
|
107 |
/************************************************************
|
|
108 |
Opens a buffer to mlog. It must be closed with mlog_close. */
|
|
109 |
UNIV_INLINE
|
|
110 |
byte* |
|
111 |
mlog_open( |
|
112 |
/*======*/
|
|
113 |
/* out: buffer, NULL if log mode MTR_LOG_NONE */
|
|
114 |
mtr_t* mtr, /* in: mtr */ |
|
115 |
ulint size); /* in: buffer size in bytes; MUST be |
|
116 |
smaller than DYN_ARRAY_DATA_SIZE! */
|
|
117 |
/************************************************************
|
|
118 |
Closes a buffer opened to mlog. */
|
|
119 |
UNIV_INLINE
|
|
120 |
void
|
|
121 |
mlog_close( |
|
122 |
/*=======*/
|
|
123 |
mtr_t* mtr, /* in: mtr */ |
|
124 |
byte* ptr); /* in: buffer space from ptr up was not used */ |
|
125 |
/************************************************************
|
|
126 |
Writes the initial part of a log record (3..11 bytes).
|
|
127 |
If the implementation of this function is changed, all
|
|
128 |
size parameters to mlog_open() should be adjusted accordingly! */
|
|
129 |
UNIV_INLINE
|
|
130 |
byte* |
|
131 |
mlog_write_initial_log_record_fast( |
|
132 |
/*===============================*/
|
|
133 |
/* out: new value of log_ptr */
|
|
134 |
byte* ptr, /* in: pointer to (inside) a buffer frame holding the |
|
135 |
file page where modification is made */
|
|
136 |
byte type, /* in: log item type: MLOG_1BYTE, ... */ |
|
137 |
byte* log_ptr,/* in: pointer to mtr log which has been opened */ |
|
138 |
mtr_t* mtr); /* in: mtr */ |
|
139 |
/************************************************************
|
|
140 |
Parses an initial log record written by mlog_write_initial_log_record. */
|
|
141 |
||
142 |
byte* |
|
143 |
mlog_parse_initial_log_record( |
|
144 |
/*==========================*/
|
|
145 |
/* out: parsed record end, NULL if not a complete
|
|
146 |
record */
|
|
147 |
byte* ptr, /* in: buffer */ |
|
148 |
byte* end_ptr,/* in: buffer end */ |
|
149 |
byte* type, /* out: log record type: MLOG_1BYTE, ... */ |
|
150 |
ulint* space, /* out: space id */ |
|
151 |
ulint* page_no);/* out: page number */ |
|
152 |
/************************************************************
|
|
153 |
Parses a log record written by mlog_write_ulint or mlog_write_dulint. */
|
|
154 |
||
155 |
byte* |
|
156 |
mlog_parse_nbytes( |
|
157 |
/*==============*/
|
|
158 |
/* out: parsed record end, NULL if not a complete
|
|
159 |
record */
|
|
160 |
ulint type, /* in: log record type: MLOG_1BYTE, ... */ |
|
161 |
byte* ptr, /* in: buffer */ |
|
162 |
byte* end_ptr,/* in: buffer end */ |
|
163 |
byte* page); /* in: page where to apply the log record, or NULL */ |
|
164 |
/************************************************************
|
|
165 |
Parses a log record written by mlog_write_string. */
|
|
166 |
||
167 |
byte* |
|
168 |
mlog_parse_string( |
|
169 |
/*==============*/
|
|
170 |
/* out: parsed record end, NULL if not a complete
|
|
171 |
record */
|
|
172 |
byte* ptr, /* in: buffer */ |
|
173 |
byte* end_ptr,/* in: buffer end */ |
|
174 |
byte* page); /* in: page where to apply the log record, or NULL */ |
|
175 |
||
176 |
||
177 |
/************************************************************
|
|
178 |
Opens a buffer for mlog, writes the initial log record and,
|
|
179 |
if needed, the field lengths of an index. Reserves space
|
|
180 |
for further log entries. The log entry must be closed with
|
|
181 |
mtr_close(). */
|
|
182 |
||
183 |
byte* |
|
184 |
mlog_open_and_write_index( |
|
185 |
/*======================*/
|
|
186 |
/* out: buffer, NULL if log mode
|
|
187 |
MTR_LOG_NONE */
|
|
188 |
mtr_t* mtr, /* in: mtr */ |
|
189 |
byte* rec, /* in: index record or page */ |
|
190 |
dict_index_t* index, /* in: record descriptor */ |
|
191 |
byte type, /* in: log item type */ |
|
192 |
ulint size); /* in: requested buffer size in bytes |
|
193 |
(if 0, calls mlog_close() and returns NULL) */
|
|
194 |
||
195 |
/************************************************************
|
|
196 |
Parses a log record written by mlog_open_and_write_index. */
|
|
197 |
||
198 |
byte* |
|
199 |
mlog_parse_index( |
|
200 |
/*=============*/
|
|
201 |
/* out: parsed record end,
|
|
202 |
NULL if not a complete record */
|
|
203 |
byte* ptr, /* in: buffer */ |
|
204 |
byte* end_ptr,/* in: buffer end */ |
|
205 |
/* out: new value of log_ptr */
|
|
206 |
ibool comp, /* in: TRUE=compact record format */ |
|
207 |
dict_index_t** index); /* out, own: dummy index */ |
|
208 |
||
209 |
/* Insert, update, and maybe other functions may use this value to define an
|
|
210 |
extra mlog buffer size for variable size data */
|
|
211 |
#define MLOG_BUF_MARGIN 256
|
|
212 |
||
213 |
#ifndef UNIV_NONINL
|
|
214 |
#include "mtr0log.ic" |
|
215 |
#endif
|
|
216 |
||
217 |
#endif
|