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