drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
mtr0mtr.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
26#pragma once
27#ifndef mtr0mtr_h
28#define mtr0mtr_h
29
30#include "univ.i"
31#include "mem0mem.h"
32#include "dyn0dyn.h"
33#include "buf0types.h"
34#include "sync0rw.h"
35#include "ut0byte.h"
36#include "mtr0types.h"
37#include "page0types.h"
38
39/* Logging modes for a mini-transaction */
40#define MTR_LOG_ALL 21 /* default mode: log all operations
41 modifying disk-based data */
42#define MTR_LOG_NONE 22 /* log no operations */
43/*#define MTR_LOG_SPACE 23 */ /* log only operations modifying
44 file space page allocation data
45 (operations in fsp0fsp.* ) */
46#define MTR_LOG_SHORT_INSERTS 24 /* inserts are logged in a shorter
47 form */
48
49/* Types for the mlock objects to store in the mtr memo; NOTE that the
50first 3 values must be RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
51#define MTR_MEMO_PAGE_S_FIX RW_S_LATCH
52#define MTR_MEMO_PAGE_X_FIX RW_X_LATCH
53#define MTR_MEMO_BUF_FIX RW_NO_LATCH
54#define MTR_MEMO_MODIFY 54
55#define MTR_MEMO_S_LOCK 55
56#define MTR_MEMO_X_LOCK 56
57
62#define MLOG_SINGLE_REC_FLAG 128
68#define MLOG_1BYTE (1)
69#define MLOG_2BYTES (2)
70#define MLOG_4BYTES (4)
71#define MLOG_8BYTES (8)
72#define MLOG_REC_INSERT ((byte)9)
73#define MLOG_REC_CLUST_DELETE_MARK ((byte)10)
75#define MLOG_REC_SEC_DELETE_MARK ((byte)11)
77#define MLOG_REC_UPDATE_IN_PLACE ((byte)13)
79#define MLOG_REC_DELETE ((byte)14)
81#define MLOG_LIST_END_DELETE ((byte)15)
83#define MLOG_LIST_START_DELETE ((byte)16)
85#define MLOG_LIST_END_COPY_CREATED ((byte)17)
87#define MLOG_PAGE_REORGANIZE ((byte)18)
90#define MLOG_PAGE_CREATE ((byte)19)
91#define MLOG_UNDO_INSERT ((byte)20)
93#define MLOG_UNDO_ERASE_END ((byte)21)
95#define MLOG_UNDO_INIT ((byte)22)
97#define MLOG_UNDO_HDR_DISCARD ((byte)23)
99#define MLOG_UNDO_HDR_REUSE ((byte)24)
101#define MLOG_UNDO_HDR_CREATE ((byte)25)
103#define MLOG_REC_MIN_MARK ((byte)26)
107#define MLOG_IBUF_BITMAP_INIT ((byte)27)
109/*#define MLOG_FULL_PAGE ((byte)28) full contents of a page */
110#ifdef UNIV_LOG_LSN_DEBUG
111# define MLOG_LSN ((byte)28) /* current LSN */
112#endif
113#define MLOG_INIT_FILE_PAGE ((byte)29)
122#define MLOG_WRITE_STRING ((byte)30)
124#define MLOG_MULTI_REC_END ((byte)31)
128#define MLOG_DUMMY_RECORD ((byte)32)
130#define MLOG_FILE_CREATE ((byte)33)
132#define MLOG_FILE_RENAME ((byte)34)
134#define MLOG_FILE_DELETE ((byte)35)
136#define MLOG_COMP_REC_MIN_MARK ((byte)36)
140#define MLOG_COMP_PAGE_CREATE ((byte)37)
142#define MLOG_COMP_REC_INSERT ((byte)38)
143#define MLOG_COMP_REC_CLUST_DELETE_MARK ((byte)39)
147#define MLOG_COMP_REC_SEC_DELETE_MARK ((byte)40)
155#define MLOG_COMP_REC_UPDATE_IN_PLACE ((byte)41)
159#define MLOG_COMP_REC_DELETE ((byte)42)
161#define MLOG_COMP_LIST_END_DELETE ((byte)43)
163#define MLOG_COMP_LIST_START_DELETE ((byte)44)
165#define MLOG_COMP_LIST_END_COPY_CREATED ((byte)45)
170#define MLOG_COMP_PAGE_REORGANIZE ((byte)46)
171#define MLOG_FILE_CREATE2 ((byte)47)
173#define MLOG_ZIP_WRITE_NODE_PTR ((byte)48)
176#define MLOG_ZIP_WRITE_BLOB_PTR ((byte)49)
179#define MLOG_ZIP_WRITE_HEADER ((byte)50)
181#define MLOG_ZIP_PAGE_COMPRESS ((byte)51)
182#define MLOG_BIGGEST_TYPE ((byte)51)
184/* @} */
185
189#define MLOG_FILE_FLAG_TEMP 1
191/* @} */
192
193/***************************************************************/
195UNIV_INLINE
196void
198/*======*/
199 mtr_t* mtr)
200 __attribute__((nonnull));
201/***************************************************************/
203UNIV_INTERN
204void
206/*=======*/
207 mtr_t* mtr)
208 __attribute__((nonnull));
209/**********************************************************/
212UNIV_INLINE
213ulint
215/*==============*/
216 mtr_t* mtr);
217/**********************************************************/
221UNIV_INTERN
222void
224/*======================*/
225 mtr_t* mtr,
226 ulint savepoint);
227#ifndef UNIV_HOTBACKUP
228/**********************************************************/
231UNIV_INLINE
232void
234/*=============================*/
235 mtr_t* mtr,
236 ulint savepoint,
237 rw_lock_t* lock);
238#else /* !UNIV_HOTBACKUP */
239# define mtr_release_s_latch_at_savepoint(mtr,savepoint,lock) ((void) 0)
240#endif /* !UNIV_HOTBACKUP */
241/***************************************************************/
244UNIV_INLINE
245ulint
247/*=============*/
248 mtr_t* mtr);
249/***************************************************************/
252UNIV_INLINE
253ulint
255/*=============*/
256 mtr_t* mtr,
257 ulint mode);
258/********************************************************/
261UNIV_INTERN
262ulint
264/*===========*/
265 const byte* ptr,
266 ulint type,
267 mtr_t* mtr);
268#ifndef UNIV_HOTBACKUP
269/*********************************************************************/
271#define mtr_s_lock(B, MTR) mtr_s_lock_func((B), __FILE__, __LINE__,\
272 (MTR))
273/*********************************************************************/
275#define mtr_x_lock(B, MTR) mtr_x_lock_func((B), __FILE__, __LINE__,\
276 (MTR))
277/*********************************************************************/
280UNIV_INLINE
281void
283/*============*/
284 rw_lock_t* lock,
285 const char* file,
286 ulint line,
287 mtr_t* mtr);
288/*********************************************************************/
291UNIV_INLINE
292void
294/*============*/
295 rw_lock_t* lock,
296 const char* file,
297 ulint line,
298 mtr_t* mtr);
299#endif /* !UNIV_HOTBACKUP */
300
301/***************************************************/
303UNIV_INTERN
304void
306/*=============*/
307 mtr_t* mtr,
308 void* object,
309 ulint type);
310#ifdef UNIV_DEBUG
311# ifndef UNIV_HOTBACKUP
312/**********************************************************/
315UNIV_INLINE
316ibool
317mtr_memo_contains(
318/*==============*/
319 mtr_t* mtr,
320 const void* object,
321 ulint type);
322
323/**********************************************************/
326UNIV_INTERN
327ibool
328mtr_memo_contains_page(
329/*===================*/
330 mtr_t* mtr,
331 const byte* ptr,
332 ulint type);
333/*********************************************************/
335UNIV_INTERN
336void
337mtr_print(
338/*======*/
339 mtr_t* mtr);
340# else /* !UNIV_HOTBACKUP */
341# define mtr_memo_contains(mtr, object, type) TRUE
342# define mtr_memo_contains_page(mtr, ptr, type) TRUE
343# endif /* !UNIV_HOTBACKUP */
344#endif /* UNIV_DEBUG */
345/*######################################################################*/
346
347#define MTR_BUF_MEMO_SIZE 200 /* number of slots in memo */
348
349/***************************************************************/
352UNIV_INLINE
355/*========*/
356 mtr_t* mtr);
357/***************************************************/
359UNIV_INLINE
360void
362/*==========*/
363 mtr_t* mtr,
364 void* object,
365 ulint type);
366
367
368/* Type definition of a mini-transaction memo stack slot. */
369typedef struct mtr_memo_slot_struct mtr_memo_slot_t;
371 ulint type;
372 void* object;
373};
375/* Mini-transaction handle and buffer */
376struct mtr_struct{
377#ifdef UNIV_DEBUG
378 ulint state;
379#endif
382 ibool inside_ibuf;
384 ibool modifications;
385 /* TRUE if the mtr made modifications to
386 buffer pool pages */
387 ulint n_log_recs;
388 /* count of how many page initial log records
389 have been written to the mtr log */
390 ulint log_mode; /* specifies which operations should be
391 logged; default value MTR_LOG_ALL */
392 ib_uint64_t start_lsn;/* start lsn of the possible log entry for
393 this mtr */
394 ib_uint64_t end_lsn;/* end lsn of the possible log entry for
395 this mtr */
396#ifdef UNIV_DEBUG
397 ulint magic_n;
398#endif /* UNIV_DEBUG */
399};
400
401#ifdef UNIV_DEBUG
402# define MTR_MAGIC_N 54551
403#endif /* UNIV_DEBUG */
404
405#define MTR_ACTIVE 12231
406#define MTR_COMMITTING 56456
407#define MTR_COMMITTED 34676
408
409#ifndef UNIV_NONINL
410#include "mtr0mtr.ic"
411#endif
412
413#endif
dyn_block_t dyn_array_t
Definition dyn0dyn.h:37
UNIV_INTERN ulint mtr_read_ulint(const byte *ptr, ulint type, mtr_t *mtr)
Definition mtr0mtr.cc:362
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
Definition mtr0mtr.cc:247
UNIV_INTERN void mtr_rollback_to_savepoint(mtr_t *mtr, ulint savepoint)
Definition mtr0mtr.cc:280
UNIV_INLINE void mtr_release_s_latch_at_savepoint(mtr_t *mtr, ulint savepoint, rw_lock_t *lock)
UNIV_INLINE void mtr_memo_push(mtr_t *mtr, void *object, ulint type)
UNIV_INTERN void mtr_memo_release(mtr_t *mtr, void *object, ulint type)
Definition mtr0mtr.cc:316
UNIV_INLINE dyn_array_t * mtr_get_log(mtr_t *mtr)
UNIV_INLINE void mtr_x_lock_func(rw_lock_t *lock, const char *file, ulint line, mtr_t *mtr)
UNIV_INLINE ulint mtr_get_log_mode(mtr_t *mtr)
UNIV_INLINE void mtr_s_lock_func(rw_lock_t *lock, const char *file, ulint line, mtr_t *mtr)
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
UNIV_INLINE ulint mtr_set_savepoint(mtr_t *mtr)
UNIV_INLINE ulint mtr_set_log_mode(mtr_t *mtr, ulint mode)
ibool inside_ibuf
Definition mtr0mtr.h:380
dyn_array_t log
Definition mtr0mtr.h:379
dyn_array_t memo
Definition mtr0mtr.h:378