~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/mtr0log.h

  • Committer: Brian Aker
  • Date: 2009-06-26 00:37:27 UTC
  • Revision ID: brian@gaz-20090626003727-b2y4gitpptzbvypd
Fix for CentOS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
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
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/mtr0log.h
21
 
Mini-transaction logging routines
22
 
 
23
 
Created 12/7/1995 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef mtr0log_h
27
 
#define mtr0log_h
28
 
 
29
 
#include "univ.i"
30
 
#include "mtr0mtr.h"
31
 
#include "dict0types.h"
32
 
 
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. */
37
 
UNIV_INTERN
38
 
void
39
 
mlog_write_ulint(
40
 
/*=============*/
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. */
48
 
UNIV_INTERN
49
 
void
50
 
mlog_write_ull(
51
 
/*===========*/
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. */
58
 
UNIV_INTERN
59
 
void
60
 
mlog_write_string(
61
 
/*==============*/
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. */
69
 
UNIV_INTERN
70
 
void
71
 
mlog_log_string(
72
 
/*============*/
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. */
79
 
UNIV_INTERN
80
 
void
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 */
91
 
UNIV_INLINE
92
 
byte*
93
 
mlog_write_initial_log_record_for_file_op(
94
 
/*======================================*/
95
 
        ulint   type,   /*!< in: MLOG_FILE_CREATE, MLOG_FILE_DELETE, or
96
 
                        MLOG_FILE_RENAME */
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. */
103
 
UNIV_INLINE
104
 
void
105
 
mlog_catenate_ulint(
106
 
/*================*/
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. */
112
 
UNIV_INTERN
113
 
void
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. */
121
 
UNIV_INLINE
122
 
void
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. */
129
 
UNIV_INLINE
130
 
void
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 */
138
 
UNIV_INLINE
139
 
byte*
140
 
mlog_open(
141
 
/*======*/
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. */
147
 
UNIV_INLINE
148
 
void
149
 
mlog_close(
150
 
/*=======*/
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 */
158
 
UNIV_INLINE
159
 
byte*
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
167
 
                                been opened */
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 */
176
 
UNIV_INTERN
177
 
byte*
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 */
188
 
UNIV_INTERN
189
 
byte*
190
 
mlog_parse_nbytes(
191
 
/*==============*/
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 */
200
 
UNIV_INTERN
201
 
byte*
202
 
mlog_parse_string(
203
 
/*==============*/
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 */
208
 
 
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
214
 
mtr_close().
215
 
@return buffer, NULL if log mode MTR_LOG_NONE */
216
 
UNIV_INTERN
217
 
byte*
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 */
227
 
 
228
 
/********************************************************//**
229
 
Parses a log record written by mlog_open_and_write_index.
230
 
@return parsed record end, NULL if not a complete record */
231
 
UNIV_INTERN
232
 
byte*
233
 
mlog_parse_index(
234
 
/*=============*/
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 */
239
 
 
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 */
245
 
 
246
 
#ifndef UNIV_NONINL
247
 
#include "mtr0log.ic"
248
 
#endif
249
 
 
250
 
#endif