1
/*****************************************************************************
3
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
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.
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.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/mtr0log.h
21
Mini-transaction logging routines
23
Created 12/7/1995 Heikki Tuuri
24
*******************************************************/
31
#include "dict0types.h"
33
#ifndef UNIV_HOTBACKUP
34
/********************************************************//**
35
Writes 1 - 4 bytes to a file page buffered in the buffer pool.
36
Writes the corresponding log record to the mini-transaction log. */
41
byte* ptr, /*!< in: pointer where to write */
42
ulint val, /*!< in: value to write */
43
byte type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
44
mtr_t* mtr); /*!< in: mini-transaction handle */
45
/********************************************************//**
46
Writes 8 bytes to a file page buffered in the buffer pool.
47
Writes the corresponding log record to the mini-transaction log. */
52
byte* ptr, /*!< in: pointer where to write */
53
ib_uint64_t val, /*!< in: value to write */
54
mtr_t* mtr); /*!< in: mini-transaction handle */
55
/********************************************************//**
56
Writes a string to a file page buffered in the buffer pool. Writes the
57
corresponding log record to the mini-transaction log. */
62
byte* ptr, /*!< in: pointer where to write */
63
const byte* str, /*!< in: string to write */
64
ulint len, /*!< in: string length */
65
mtr_t* mtr); /*!< in: mini-transaction handle */
66
/********************************************************//**
67
Logs a write of a string to a file page buffered in the buffer pool.
68
Writes the corresponding log record to the mini-transaction log. */
73
byte* ptr, /*!< in: pointer written to */
74
ulint len, /*!< in: string length */
75
mtr_t* mtr); /*!< in: mini-transaction handle */
76
/********************************************************//**
77
Writes initial part of a log record consisting of one-byte item
78
type and four-byte space and page numbers. */
81
mlog_write_initial_log_record(
82
/*==========================*/
83
const byte* ptr, /*!< in: pointer to (inside) a buffer
84
frame holding the file page where
85
modification is made */
86
byte type, /*!< in: log item type: MLOG_1BYTE, ... */
87
mtr_t* mtr); /*!< in: mini-transaction handle */
88
/********************************************************//**
89
Writes a log record about an .ibd file create/delete/rename.
90
@return new value of log_ptr */
93
mlog_write_initial_log_record_for_file_op(
94
/*======================================*/
95
ulint type, /*!< in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or
97
ulint space_id,/*!< in: space id, if applicable */
98
ulint page_no,/*!< in: page number (not relevant currently) */
99
byte* log_ptr,/*!< in: pointer to mtr log which has been opened */
100
mtr_t* mtr); /*!< in: mtr */
101
/********************************************************//**
102
Catenates 1 - 4 bytes to the mtr log. */
107
mtr_t* mtr, /*!< in: mtr */
108
ulint val, /*!< in: value to write */
109
ulint type); /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
110
/********************************************************//**
111
Catenates n bytes to the mtr log. */
114
mlog_catenate_string(
115
/*=================*/
116
mtr_t* mtr, /*!< in: mtr */
117
const byte* str, /*!< in: string to write */
118
ulint len); /*!< in: string length */
119
/********************************************************//**
120
Catenates a compressed ulint to mlog. */
123
mlog_catenate_ulint_compressed(
124
/*===========================*/
125
mtr_t* mtr, /*!< in: mtr */
126
ulint val); /*!< in: value to write */
127
/********************************************************//**
128
Catenates a compressed 64-bit integer to mlog. */
131
mlog_catenate_ull_compressed(
132
/*=========================*/
133
mtr_t* mtr, /*!< in: mtr */
134
ib_uint64_t val); /*!< in: value to write */
135
/********************************************************//**
136
Opens a buffer to mlog. It must be closed with mlog_close.
137
@return buffer, NULL if log mode MTR_LOG_NONE */
142
mtr_t* mtr, /*!< in: mtr */
143
ulint size); /*!< in: buffer size in bytes; MUST be
144
smaller than DYN_ARRAY_DATA_SIZE! */
145
/********************************************************//**
146
Closes a buffer opened to mlog. */
151
mtr_t* mtr, /*!< in: mtr */
152
byte* ptr); /*!< in: buffer space from ptr up was not used */
153
/********************************************************//**
154
Writes the initial part of a log record (3..11 bytes).
155
If the implementation of this function is changed, all
156
size parameters to mlog_open() should be adjusted accordingly!
157
@return new value of log_ptr */
160
mlog_write_initial_log_record_fast(
161
/*===============================*/
162
const byte* ptr, /*!< in: pointer to (inside) a buffer
163
frame holding the file page where
164
modification is made */
165
byte type, /*!< in: log item type: MLOG_1BYTE, ... */
166
byte* log_ptr,/*!< in: pointer to mtr log which has
168
mtr_t* mtr); /*!< in: mtr */
169
#else /* !UNIV_HOTBACKUP */
170
# define mlog_write_initial_log_record(ptr,type,mtr) ((void) 0)
171
# define mlog_write_initial_log_record_fast(ptr,type,log_ptr,mtr) ((byte *) 0)
172
#endif /* !UNIV_HOTBACKUP */
173
/********************************************************//**
174
Parses an initial log record written by mlog_write_initial_log_record.
175
@return parsed record end, NULL if not a complete record */
178
mlog_parse_initial_log_record(
179
/*==========================*/
180
byte* ptr, /*!< in: buffer */
181
byte* end_ptr,/*!< in: buffer end */
182
byte* type, /*!< out: log record type: MLOG_1BYTE, ... */
183
ulint* space, /*!< out: space id */
184
ulint* page_no);/*!< out: page number */
185
/********************************************************//**
186
Parses a log record written by mlog_write_ulint or mlog_write_ull.
187
@return parsed record end, NULL if not a complete record */
192
ulint type, /*!< in: log record type: MLOG_1BYTE, ... */
193
byte* ptr, /*!< in: buffer */
194
byte* end_ptr,/*!< in: buffer end */
195
byte* page, /*!< in: page where to apply the log record, or NULL */
196
void* page_zip);/*!< in/out: compressed page, or NULL */
197
/********************************************************//**
198
Parses a log record written by mlog_write_string.
199
@return parsed record end, NULL if not a complete record */
204
byte* ptr, /*!< in: buffer */
205
byte* end_ptr,/*!< in: buffer end */
206
byte* page, /*!< in: page where to apply the log record, or NULL */
207
void* page_zip);/*!< in/out: compressed page, or NULL */
209
#ifndef UNIV_HOTBACKUP
210
/********************************************************//**
211
Opens a buffer for mlog, writes the initial log record and,
212
if needed, the field lengths of an index. Reserves space
213
for further log entries. The log entry must be closed with
215
@return buffer, NULL if log mode MTR_LOG_NONE */
218
mlog_open_and_write_index(
219
/*======================*/
220
mtr_t* mtr, /*!< in: mtr */
221
const byte* rec, /*!< in: index record or page */
222
dict_index_t* index, /*!< in: record descriptor */
223
byte type, /*!< in: log item type */
224
ulint size); /*!< in: requested buffer size in bytes
225
(if 0, calls mlog_close() and returns NULL) */
226
#endif /* !UNIV_HOTBACKUP */
228
/********************************************************//**
229
Parses a log record written by mlog_open_and_write_index.
230
@return parsed record end, NULL if not a complete record */
235
byte* ptr, /*!< in: buffer */
236
const byte* end_ptr,/*!< in: buffer end */
237
ibool comp, /*!< in: TRUE=compact record format */
238
dict_index_t** index); /*!< out, own: dummy index */
240
#ifndef UNIV_HOTBACKUP
241
/* Insert, update, and maybe other functions may use this value to define an
242
extra mlog buffer size for variable size data */
243
#define MLOG_BUF_MARGIN 256
244
#endif /* !UNIV_HOTBACKUP */
247
#include "mtr0log.ic"