1
/******************************************************
2
Mini-transaction logging routines
6
Created 12/7/1995 Heikki Tuuri
7
*******************************************************/
14
#include "dict0types.h"
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. */
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. */
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. */
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
Logs a write of a string to a file page buffered in the buffer pool.
50
Writes the corresponding log record to the mini-transaction log. */
55
byte* ptr, /* in: pointer written to */
56
ulint len, /* in: string length */
57
mtr_t* mtr); /* in: mini-transaction handle */
58
/************************************************************
59
Writes initial part of a log record consisting of one-byte item
60
type and four-byte space and page numbers. */
63
mlog_write_initial_log_record(
64
/*==========================*/
65
const byte* ptr, /* in: pointer to (inside) a buffer
66
frame holding the file page where
67
modification is made */
68
byte type, /* in: log item type: MLOG_1BYTE, ... */
69
mtr_t* mtr); /* in: mini-transaction handle */
70
/************************************************************
71
Writes a log record about an .ibd file create/delete/rename. */
74
mlog_write_initial_log_record_for_file_op(
75
/*======================================*/
76
/* out: new value of log_ptr */
77
ulint type, /* in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or
79
ulint space_id,/* in: space id, if applicable */
80
ulint page_no,/* in: page number (not relevant currently) */
81
byte* log_ptr,/* in: pointer to mtr log which has been opened */
82
mtr_t* mtr); /* in: mtr */
83
/************************************************************
84
Catenates 1 - 4 bytes to the mtr log. */
89
mtr_t* mtr, /* in: mtr */
90
ulint val, /* in: value to write */
91
ulint type); /* in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
92
/************************************************************
93
Catenates n bytes to the mtr log. */
98
mtr_t* mtr, /* in: mtr */
99
const byte* str, /* in: string to write */
100
ulint len); /* in: string length */
101
/************************************************************
102
Catenates a compressed ulint to mlog. */
105
mlog_catenate_ulint_compressed(
106
/*===========================*/
107
mtr_t* mtr, /* in: mtr */
108
ulint val); /* in: value to write */
109
/************************************************************
110
Catenates a compressed dulint to mlog. */
113
mlog_catenate_dulint_compressed(
114
/*============================*/
115
mtr_t* mtr, /* in: mtr */
116
dulint val); /* in: value to write */
117
/************************************************************
118
Opens a buffer to mlog. It must be closed with mlog_close. */
123
/* out: buffer, NULL if log mode MTR_LOG_NONE */
124
mtr_t* mtr, /* in: mtr */
125
ulint size); /* in: buffer size in bytes; MUST be
126
smaller than DYN_ARRAY_DATA_SIZE! */
127
/************************************************************
128
Closes a buffer opened to mlog. */
133
mtr_t* mtr, /* in: mtr */
134
byte* ptr); /* in: buffer space from ptr up was not used */
135
/************************************************************
136
Writes the initial part of a log record (3..11 bytes).
137
If the implementation of this function is changed, all
138
size parameters to mlog_open() should be adjusted accordingly! */
141
mlog_write_initial_log_record_fast(
142
/*===============================*/
143
/* out: new value of log_ptr */
144
const byte* ptr, /* in: pointer to (inside) a buffer
145
frame holding the file page where
146
modification is made */
147
byte type, /* in: log item type: MLOG_1BYTE, ... */
148
byte* log_ptr,/* in: pointer to mtr log which has
150
mtr_t* mtr); /* in: mtr */
151
/************************************************************
152
Parses an initial log record written by mlog_write_initial_log_record. */
155
mlog_parse_initial_log_record(
156
/*==========================*/
157
/* out: parsed record end, NULL if not a complete
159
byte* ptr, /* in: buffer */
160
byte* end_ptr,/* in: buffer end */
161
byte* type, /* out: log record type: MLOG_1BYTE, ... */
162
ulint* space, /* out: space id */
163
ulint* page_no);/* out: page number */
164
/************************************************************
165
Parses a log record written by mlog_write_ulint or mlog_write_dulint. */
170
/* out: parsed record end, NULL if not a complete
172
ulint type, /* in: log record type: MLOG_1BYTE, ... */
173
byte* ptr, /* in: buffer */
174
byte* end_ptr,/* in: buffer end */
175
byte* page, /* in: page where to apply the log record, or NULL */
176
void* page_zip);/* in/out: compressed page, or NULL */
177
/************************************************************
178
Parses a log record written by mlog_write_string. */
183
/* out: parsed record end, NULL if not a complete
185
byte* ptr, /* in: buffer */
186
byte* end_ptr,/* in: buffer end */
187
byte* page, /* in: page where to apply the log record, or NULL */
188
void* page_zip);/* in/out: compressed page, or NULL */
191
/************************************************************
192
Opens a buffer for mlog, writes the initial log record and,
193
if needed, the field lengths of an index. Reserves space
194
for further log entries. The log entry must be closed with
198
mlog_open_and_write_index(
199
/*======================*/
200
/* out: buffer, NULL if log mode
202
mtr_t* mtr, /* in: mtr */
203
byte* rec, /* in: index record or page */
204
dict_index_t* index, /* in: record descriptor */
205
byte type, /* in: log item type */
206
ulint size); /* in: requested buffer size in bytes
207
(if 0, calls mlog_close() and returns NULL) */
209
/************************************************************
210
Parses a log record written by mlog_open_and_write_index. */
215
/* out: parsed record end,
216
NULL if not a complete record */
217
byte* ptr, /* in: buffer */
218
byte* end_ptr,/* in: buffer end */
219
/* out: new value of log_ptr */
220
ibool comp, /* in: TRUE=compact record format */
221
dict_index_t** index); /* out, own: dummy index */
223
/* Insert, update, and maybe other functions may use this value to define an
224
extra mlog buffer size for variable size data */
225
#define MLOG_BUF_MARGIN 256
228
#include "mtr0log.ic"