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
Writes initial part of a log record consisting of one-byte item
50
type and four-byte space and page numbers. */
53
mlog_write_initial_log_record(
54
/*==========================*/
55
byte* ptr, /* in: pointer to (inside) a buffer frame
56
holding the file page where modification
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. */
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
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. */
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. */
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. */
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. */
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. */
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. */
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! */
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. */
143
mlog_parse_initial_log_record(
144
/*==========================*/
145
/* out: parsed record end, NULL if not a complete
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. */
158
/* out: parsed record end, NULL if not a complete
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. */
170
/* out: parsed record end, NULL if not a complete
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 */
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
184
mlog_open_and_write_index(
185
/*======================*/
186
/* out: buffer, NULL if log mode
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) */
195
/************************************************************
196
Parses a log record written by mlog_open_and_write_index. */
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 */
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
214
#include "mtr0log.ic"