641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
1819.5.221
by vasil
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6749 from MySQL InnoDB |
3 |
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify it under
|
|
6 |
the terms of the GNU General Public License as published by the Free Software
|
|
7 |
Foundation; version 2 of the License.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License along with
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
15 |
St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
16 |
|
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/log0log.ic
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
Database log
|
22 |
||
23 |
Created 12/9/1995 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#include "os0file.h" |
|
27 |
#include "mach0data.h" |
|
28 |
#include "mtr0mtr.h" |
|
29 |
||
1819.5.29
by stewart at flamingspork
[patch 029/129] Merge patch for revision 1817 from InnoDB SVN: |
30 |
#ifdef UNIV_LOG_DEBUG |
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
31 |
/******************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
32 |
Checks by parsing that the catenated log segment for a single mtr is
|
33 |
consistent. */
|
|
34 |
UNIV_INTERN
|
|
35 |
ibool
|
|
36 |
log_check_log_recs( |
|
37 |
/*===============*/
|
|
1819.5.29
by stewart at flamingspork
[patch 029/129] Merge patch for revision 1817 from InnoDB SVN: |
38 |
const byte* buf, /*!< in: pointer to the start of |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
39 |
the log segment in the
|
40 |
log_sys->buf log buffer */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
41 |
ulint len, /*!< in: segment length in bytes */ |
42 |
ib_uint64_t buf_start_lsn); /*!< in: buffer start lsn */ |
|
1819.5.29
by stewart at flamingspork
[patch 029/129] Merge patch for revision 1817 from InnoDB SVN: |
43 |
#endif /* UNIV_LOG_DEBUG */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
44 |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
45 |
/************************************************************//**
|
46 |
Gets a log block flush bit.
|
|
47 |
@return TRUE if this block was the first to be written in a log flush */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
48 |
UNIV_INLINE
|
49 |
ibool
|
|
50 |
log_block_get_flush_bit( |
|
51 |
/*====================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
52 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
53 |
{
|
54 |
if (LOG_BLOCK_FLUSH_BIT_MASK |
|
55 |
& mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)) { |
|
56 |
||
57 |
return(TRUE); |
|
58 |
} |
|
59 |
||
60 |
return(FALSE); |
|
61 |
}
|
|
62 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
63 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
64 |
Sets the log block flush bit. */
|
65 |
UNIV_INLINE
|
|
66 |
void
|
|
67 |
log_block_set_flush_bit( |
|
68 |
/*====================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
69 |
byte* log_block, /*!< in/out: log block */ |
70 |
ibool val) /*!< in: value to set */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
71 |
{
|
72 |
ulint field; |
|
73 |
||
74 |
field = mach_read_from_4(log_block + LOG_BLOCK_HDR_NO); |
|
75 |
||
76 |
if (val) { |
|
77 |
field = field | LOG_BLOCK_FLUSH_BIT_MASK; |
|
78 |
} else { |
|
79 |
field = field & ~LOG_BLOCK_FLUSH_BIT_MASK; |
|
80 |
} |
|
81 |
||
82 |
mach_write_to_4(log_block + LOG_BLOCK_HDR_NO, field); |
|
83 |
}
|
|
84 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
85 |
/************************************************************//**
|
86 |
Gets a log block number stored in the header.
|
|
87 |
@return log block number stored in the block header */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
88 |
UNIV_INLINE
|
89 |
ulint
|
|
90 |
log_block_get_hdr_no( |
|
91 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
92 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
93 |
{
|
94 |
return(~LOG_BLOCK_FLUSH_BIT_MASK |
|
95 |
& mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)); |
|
96 |
}
|
|
97 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
98 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
99 |
Sets the log block number stored in the header; NOTE that this must be set
|
100 |
before the flush bit! */
|
|
101 |
UNIV_INLINE
|
|
102 |
void
|
|
103 |
log_block_set_hdr_no( |
|
104 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
105 |
byte* log_block, /*!< in/out: log block */ |
106 |
ulint n) /*!< in: log block number: must be > 0 and |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
107 |
< LOG_BLOCK_FLUSH_BIT_MASK */
|
108 |
{
|
|
109 |
ut_ad(n > 0); |
|
110 |
ut_ad(n < LOG_BLOCK_FLUSH_BIT_MASK); |
|
111 |
||
112 |
mach_write_to_4(log_block + LOG_BLOCK_HDR_NO, n); |
|
113 |
}
|
|
114 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
115 |
/************************************************************//**
|
116 |
Gets a log block data length.
|
|
117 |
@return log block data length measured as a byte offset from the block start */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
118 |
UNIV_INLINE
|
119 |
ulint
|
|
120 |
log_block_get_data_len( |
|
121 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
122 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
123 |
{
|
124 |
return(mach_read_from_2(log_block + LOG_BLOCK_HDR_DATA_LEN)); |
|
125 |
}
|
|
126 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
127 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
128 |
Sets the log block data length. */
|
129 |
UNIV_INLINE
|
|
130 |
void
|
|
131 |
log_block_set_data_len( |
|
132 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
133 |
byte* log_block, /*!< in/out: log block */ |
134 |
ulint len) /*!< in: data length */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
135 |
{
|
136 |
mach_write_to_2(log_block + LOG_BLOCK_HDR_DATA_LEN, len); |
|
137 |
}
|
|
138 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
139 |
/************************************************************//**
|
140 |
Gets a log block first mtr log record group offset.
|
|
141 |
@return first mtr log record group byte offset from the block start, 0
|
|
142 |
if none */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
143 |
UNIV_INLINE
|
144 |
ulint
|
|
145 |
log_block_get_first_rec_group( |
|
146 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
147 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
148 |
{
|
149 |
return(mach_read_from_2(log_block + LOG_BLOCK_FIRST_REC_GROUP)); |
|
150 |
}
|
|
151 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
152 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
153 |
Sets the log block first mtr log record group offset. */
|
154 |
UNIV_INLINE
|
|
155 |
void
|
|
156 |
log_block_set_first_rec_group( |
|
157 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
158 |
byte* log_block, /*!< in/out: log block */ |
159 |
ulint offset) /*!< in: offset, 0 if none */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
160 |
{
|
161 |
mach_write_to_2(log_block + LOG_BLOCK_FIRST_REC_GROUP, offset); |
|
162 |
}
|
|
163 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
164 |
/************************************************************//**
|
165 |
Gets a log block checkpoint number field (4 lowest bytes).
|
|
166 |
@return checkpoint no (4 lowest bytes) */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
167 |
UNIV_INLINE
|
168 |
ulint
|
|
169 |
log_block_get_checkpoint_no( |
|
170 |
/*========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
171 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
172 |
{
|
173 |
return(mach_read_from_4(log_block + LOG_BLOCK_CHECKPOINT_NO)); |
|
174 |
}
|
|
175 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
176 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
177 |
Sets a log block checkpoint number field (4 lowest bytes). */
|
178 |
UNIV_INLINE
|
|
179 |
void
|
|
180 |
log_block_set_checkpoint_no( |
|
181 |
/*========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
182 |
byte* log_block, /*!< in/out: log block */ |
183 |
ib_uint64_t no) /*!< in: checkpoint no */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
184 |
{
|
185 |
mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, (ulint) no); |
|
186 |
}
|
|
187 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
188 |
/************************************************************//**
|
189 |
Converts a lsn to a log block number.
|
|
190 |
@return log block number, it is > 0 and <= 1G */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
191 |
UNIV_INLINE
|
192 |
ulint
|
|
193 |
log_block_convert_lsn_to_no( |
|
194 |
/*========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
195 |
ib_uint64_t lsn) /*!< in: lsn of a byte within the block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
196 |
{
|
197 |
return(((ulint) (lsn / OS_FILE_LOG_BLOCK_SIZE) & 0x3FFFFFFFUL) + 1); |
|
198 |
}
|
|
199 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
200 |
/************************************************************//**
|
201 |
Calculates the checksum for a log block.
|
|
202 |
@return checksum */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
203 |
UNIV_INLINE
|
204 |
ulint
|
|
205 |
log_block_calc_checksum( |
|
206 |
/*====================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
207 |
const byte* block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
208 |
{
|
209 |
ulint sum; |
|
210 |
ulint sh; |
|
211 |
ulint i; |
|
212 |
||
213 |
sum = 1; |
|
214 |
sh = 0; |
|
215 |
||
216 |
for (i = 0; i < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE; i++) { |
|
217 |
ulint b = (ulint) block[i]; |
|
218 |
sum &= 0x7FFFFFFFUL; |
|
219 |
sum += b; |
|
220 |
sum += b << sh; |
|
221 |
sh++; |
|
222 |
if (sh > 24) { |
|
223 |
sh = 0; |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
return(sum); |
|
228 |
}
|
|
229 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
230 |
/************************************************************//**
|
231 |
Gets a log block checksum field value.
|
|
232 |
@return checksum */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
233 |
UNIV_INLINE
|
234 |
ulint
|
|
235 |
log_block_get_checksum( |
|
236 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
237 |
const byte* log_block) /*!< in: log block */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
238 |
{
|
239 |
return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE |
|
240 |
- LOG_BLOCK_CHECKSUM)); |
|
241 |
}
|
|
242 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
243 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
244 |
Sets a log block checksum field value. */
|
245 |
UNIV_INLINE
|
|
246 |
void
|
|
247 |
log_block_set_checksum( |
|
248 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
249 |
byte* log_block, /*!< in/out: log block */ |
250 |
ulint checksum) /*!< in: checksum */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
251 |
{
|
252 |
mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE |
|
253 |
- LOG_BLOCK_CHECKSUM, |
|
254 |
checksum); |
|
255 |
}
|
|
256 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
257 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
258 |
Initializes a log block in the log buffer. */
|
259 |
UNIV_INLINE
|
|
260 |
void
|
|
261 |
log_block_init( |
|
262 |
/*===========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
263 |
byte* log_block, /*!< in: pointer to the log buffer */ |
264 |
ib_uint64_t lsn) /*!< in: lsn within the log block */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
265 |
{
|
266 |
ulint no; |
|
267 |
||
268 |
ut_ad(mutex_own(&(log_sys->mutex))); |
|
269 |
||
270 |
no = log_block_convert_lsn_to_no(lsn); |
|
271 |
||
272 |
log_block_set_hdr_no(log_block, no); |
|
273 |
||
274 |
log_block_set_data_len(log_block, LOG_BLOCK_HDR_SIZE); |
|
275 |
log_block_set_first_rec_group(log_block, 0); |
|
276 |
}
|
|
277 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
278 |
/************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
279 |
Initializes a log block in the log buffer in the old format, where there
|
280 |
was no checksum yet. */
|
|
281 |
UNIV_INLINE
|
|
282 |
void
|
|
283 |
log_block_init_in_old_format( |
|
284 |
/*=========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
285 |
byte* log_block, /*!< in: pointer to the log buffer */ |
286 |
ib_uint64_t lsn) /*!< in: lsn within the log block */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
287 |
{
|
288 |
ulint no; |
|
289 |
||
290 |
ut_ad(mutex_own(&(log_sys->mutex))); |
|
291 |
||
292 |
no = log_block_convert_lsn_to_no(lsn); |
|
293 |
||
294 |
log_block_set_hdr_no(log_block, no); |
|
295 |
mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE |
|
296 |
- LOG_BLOCK_CHECKSUM, no); |
|
297 |
log_block_set_data_len(log_block, LOG_BLOCK_HDR_SIZE); |
|
298 |
log_block_set_first_rec_group(log_block, 0); |
|
299 |
}
|
|
300 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
301 |
#ifndef UNIV_HOTBACKUP |
302 |
/************************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
303 |
Writes to the log the string given. The log must be released with
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
304 |
log_release.
|
305 |
@return end lsn of the log record, zero if did not succeed */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
306 |
UNIV_INLINE
|
307 |
ib_uint64_t
|
|
308 |
log_reserve_and_write_fast( |
|
309 |
/*=======================*/
|
|
1819.5.27
by stewart at flamingspork
[patch 027/129] Merge patch for revision 1815 from InnoDB SVN: |
310 |
const void* str, /*!< in: string */ |
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
311 |
ulint len, /*!< in: string length */ |
1819.5.27
by stewart at flamingspork
[patch 027/129] Merge patch for revision 1815 from InnoDB SVN: |
312 |
ib_uint64_t* start_lsn)/*!< out: start lsn of the log record */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
313 |
{
|
314 |
ulint data_len; |
|
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
315 |
#ifdef UNIV_LOG_LSN_DEBUG |
316 |
/* length of the LSN pseudo-record */ |
|
1819.5.213
by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6717 from MySQL InnoDB |
317 |
ulint lsn_len; |
318 |
#endif /* UNIV_LOG_LSN_DEBUG */ |
|
319 |
||
320 |
mutex_enter(&log_sys->mutex); |
|
321 |
#ifdef UNIV_LOG_LSN_DEBUG |
|
322 |
lsn_len = 1 |
|
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
323 |
+ mach_get_compressed_size(log_sys->lsn >> 32) |
324 |
+ mach_get_compressed_size(log_sys->lsn & 0xFFFFFFFFUL); |
|
325 |
#endif /* UNIV_LOG_LSN_DEBUG */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
326 |
|
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
327 |
data_len = len |
328 |
#ifdef UNIV_LOG_LSN_DEBUG |
|
329 |
+ lsn_len |
|
330 |
#endif /* UNIV_LOG_LSN_DEBUG */ |
|
331 |
+ log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE; |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
332 |
|
333 |
if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) { |
|
334 |
||
335 |
/* The string does not fit within the current log block |
|
336 |
or the log block would become full */
|
|
337 |
||
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
338 |
mutex_exit(&log_sys->mutex); |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
339 |
|
340 |
return(0); |
|
341 |
} |
|
342 |
||
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
343 |
*start_lsn = log_sys->lsn; |
344 |
||
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
345 |
#ifdef UNIV_LOG_LSN_DEBUG |
346 |
{ |
|
347 |
/* Write the LSN pseudo-record. */ |
|
348 |
byte* b = &log_sys->buf[log_sys->buf_free]; |
|
349 |
*b++ = MLOG_LSN | (MLOG_SINGLE_REC_FLAG & *(const byte*) str); |
|
350 |
/* Write the LSN in two parts, |
|
351 |
as a pseudo page number and space id. */
|
|
352 |
b += mach_write_compressed(b, log_sys->lsn >> 32); |
|
353 |
b += mach_write_compressed(b, log_sys->lsn & 0xFFFFFFFFUL); |
|
354 |
ut_a(b - lsn_len == &log_sys->buf[log_sys->buf_free]); |
|
355 |
||
356 |
memcpy(b, str, len); |
|
357 |
len += lsn_len; |
|
358 |
} |
|
359 |
#else /* UNIV_LOG_LSN_DEBUG */ |
|
360 |
memcpy(log_sys->buf + log_sys->buf_free, str, len); |
|
361 |
#endif /* UNIV_LOG_LSN_DEBUG */ |
|
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
362 |
|
363 |
log_block_set_data_len((byte*) ut_align_down(log_sys->buf |
|
364 |
+ log_sys->buf_free, |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
365 |
OS_FILE_LOG_BLOCK_SIZE), |
366 |
data_len); |
|
367 |
#ifdef UNIV_LOG_DEBUG |
|
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
368 |
log_sys->old_buf_free = log_sys->buf_free; |
369 |
log_sys->old_lsn = log_sys->lsn; |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
370 |
#endif
|
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
371 |
log_sys->buf_free += len; |
372 |
||
373 |
ut_ad(log_sys->buf_free <= log_sys->buf_size); |
|
374 |
||
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
375 |
log_sys->lsn += len; |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
376 |
|
377 |
#ifdef UNIV_LOG_DEBUG |
|
1819.5.30
by stewart at flamingspork
[patch 030/129] Merge patch for revision 1818 from InnoDB SVN: |
378 |
log_check_log_recs(log_sys->buf + log_sys->old_buf_free, |
379 |
log_sys->buf_free - log_sys->old_buf_free, |
|
380 |
log_sys->old_lsn); |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
381 |
#endif
|
1819.5.60
by stewart at flamingspork
[patch 060/129] Merge patch for revision 1853 from InnoDB SVN: |
382 |
return(log_sys->lsn); |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
383 |
}
|
384 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
385 |
/***********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
386 |
Releases the log mutex. */
|
387 |
UNIV_INLINE
|
|
388 |
void
|
|
389 |
log_release(void) |
|
390 |
/*=============*/
|
|
391 |
{
|
|
392 |
mutex_exit(&(log_sys->mutex)); |
|
393 |
}
|
|
394 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
395 |
/************************************************************//**
|
396 |
Gets the current lsn.
|
|
397 |
@return current lsn */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
398 |
UNIV_INLINE
|
399 |
ib_uint64_t
|
|
400 |
log_get_lsn(void) |
|
401 |
/*=============*/
|
|
402 |
{
|
|
403 |
ib_uint64_t lsn; |
|
404 |
||
405 |
mutex_enter(&(log_sys->mutex)); |
|
406 |
||
407 |
lsn = log_sys->lsn; |
|
408 |
||
409 |
mutex_exit(&(log_sys->mutex)); |
|
410 |
||
411 |
return(lsn); |
|
412 |
}
|
|
413 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
414 |
/****************************************************************
|
415 |
Gets the log group capacity. It is OK to read the value without
|
|
416 |
holding log_sys->mutex because it is constant.
|
|
417 |
@return log group capacity */
|
|
418 |
UNIV_INLINE
|
|
419 |
ulint
|
|
420 |
log_get_capacity(void) |
|
421 |
/*==================*/
|
|
422 |
{
|
|
423 |
return(log_sys->log_group_capacity); |
|
424 |
}
|
|
425 |
||
426 |
/***********************************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
427 |
Checks if there is need for a log buffer flush or a new checkpoint, and does
|
428 |
this if yes. Any database operation should call this when it has modified
|
|
429 |
more than about 4 pages. NOTE that this function may only be called when the
|
|
430 |
OS thread owns no synchronization objects except the dictionary mutex. */
|
|
431 |
UNIV_INLINE
|
|
432 |
void
|
|
433 |
log_free_check(void) |
|
434 |
/*================*/
|
|
435 |
{
|
|
436 |
/* ut_ad(sync_thread_levels_empty()); */ |
|
437 |
||
438 |
if (log_sys->check_flush_or_checkpoint) { |
|
439 |
||
440 |
log_check_margins(); |
|
441 |
} |
|
442 |
}
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
443 |
#endif /* !UNIV_HOTBACKUP */ |