drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
trx0undo.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1996, 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 trx0undo_h
28#define trx0undo_h
29
30#include "univ.i"
31#include "trx0types.h"
32#include "mtr0mtr.h"
33#include "trx0sys.h"
34#include "page0types.h"
35#include "trx0xa.h"
36
37#ifndef UNIV_HOTBACKUP
38/***********************************************************************/
41UNIV_INLINE
44/*====================*/
45 ibool is_insert,
46 ulint rseg_id,
47 ulint page_no,
48 ulint offset);
49/***********************************************************************/
51UNIV_INLINE
52void
54/*=====================*/
55 roll_ptr_t roll_ptr,
56 ibool* is_insert,
57 ulint* rseg_id,
58 ulint* page_no,
59 ulint* offset);
61/***********************************************************************/
64UNIV_INLINE
65ibool
67/*========================*/
68 roll_ptr_t roll_ptr);
69#endif /* !UNIV_HOTBACKUP */
70/*****************************************************************/
74UNIV_INLINE
75void
77/*===============*/
78 byte* ptr,
80 roll_ptr_t roll_ptr);
81/*****************************************************************/
86UNIV_INLINE
89/*==============*/
90 const byte* ptr);
91#ifndef UNIV_HOTBACKUP
92/******************************************************************/
95UNIV_INLINE
96page_t*
98/*==============*/
99 ulint space,
100 ulint zip_size,
102 ulint page_no,
103 mtr_t* mtr);
104/******************************************************************/
107UNIV_INLINE
108page_t*
110/*========================*/
111 ulint space,
112 ulint zip_size,
114 ulint page_no,
115 mtr_t* mtr);
116/******************************************************************/
120UNIV_INLINE
123/*=======================*/
124 trx_undo_rec_t* rec,
125 ulint page_no,
126 ulint offset);
127/******************************************************************/
131UNIV_INLINE
134/*=======================*/
135 trx_undo_rec_t* rec,
136 ulint page_no,
137 ulint offset);
138/******************************************************************/
142UNIV_INLINE
145/*=======================*/
146 page_t* undo_page,
147 ulint page_no,
148 ulint offset);
149/******************************************************************/
153UNIV_INLINE
156/*========================*/
157 page_t* undo_page,
158 ulint page_no,
159 ulint offset);
160/***********************************************************************/
163UNIV_INTERN
166/*==================*/
167 trx_undo_rec_t* rec,
168 ulint page_no,
169 ulint offset,
170 mtr_t* mtr);
171/***********************************************************************/
174UNIV_INTERN
177/*==================*/
178 trx_undo_rec_t* rec,
179 ulint page_no,
180 ulint offset,
181 mtr_t* mtr);
182/***********************************************************************/
185UNIV_INTERN
188/*===================*/
189 ulint space,
190 ulint zip_size,
192 ulint page_no,
193 ulint offset,
194 ulint mode,
195 mtr_t* mtr);
196/********************************************************************/
199UNIV_INTERN
200ulint
202/*==============*/
203 trx_t* trx,
204 trx_undo_t* undo,
205 mtr_t* mtr);
208/***********************************************************************/
211UNIV_INTERN
212void
214/*==================*/
215 trx_t* trx,
216 trx_undo_t* undo,
217 undo_no_t limit);
219/***********************************************************************/
222UNIV_INTERN
223void
225/*====================*/
226 trx_rseg_t* rseg,
227 ulint space,
228 ulint hdr_page_no,
229 ulint hdr_offset,
230 undo_no_t limit);
237/********************************************************************/
242UNIV_INTERN
243ulint
245/*================*/
246 trx_rseg_t* rseg);
247/**********************************************************************/
253UNIV_INTERN
254ulint
256/*=================*/
257 trx_t* trx,
258 ulint type);
259/******************************************************************/
262UNIV_INTERN
263page_t*
265/*=========================*/
266 trx_undo_t* undo,
267 mtr_t* mtr);
268/******************************************************************/
271UNIV_INTERN
272page_t*
274/*==========================*/
275 trx_t* trx,
276 trx_undo_t* undo,
277 mtr_t* mtr);
278
279/**********************************************************************/
283UNIV_INTERN
284void
286/*====================*/
287 trx_t* trx,
288 page_t* undo_page,
290 mtr_t* mtr);
291/******************************************************************/
295UNIV_INTERN
296void
298/*====================*/
299 trx_t* trx);
300#endif /* !UNIV_HOTBACKUP */
301/***********************************************************/
304UNIV_INTERN
305byte*
307/*=====================*/
308 byte* ptr,
309 byte* end_ptr,
310 page_t* page,
311 mtr_t* mtr);
312/***********************************************************/
315UNIV_INTERN
316byte*
318/*=======================*/
319 ulint type,
320 byte* ptr,
321 byte* end_ptr,
322 page_t* page,
323 mtr_t* mtr);
324/***********************************************************/
327UNIV_INTERN
328byte*
330/*==========================*/
331 byte* ptr,
332 byte* end_ptr,
333 page_t* page,
334 mtr_t* mtr);
335/************************************************************************
336Frees an undo log memory copy. */
337UNIV_INTERN
338void
340/*==============*/
341 trx_undo_t* undo); /* in: the undo object to be freed */
342
343/* Types of an undo log segment */
344#define TRX_UNDO_INSERT 1 /* contains undo entries for inserts */
345#define TRX_UNDO_UPDATE 2 /* contains undo entries for updates
346 and delete markings: in short,
347 modifys (the name 'UPDATE' is a
348 historical relic) */
349/* States of an undo log segment */
350#define TRX_UNDO_ACTIVE 1 /* contains an undo log of an active
351 transaction */
352#define TRX_UNDO_CACHED 2 /* cached for quick reuse */
353#define TRX_UNDO_TO_FREE 3 /* insert undo segment can be freed */
354#define TRX_UNDO_TO_PURGE 4 /* update undo segment will not be
355 reused: it can be freed in purge when
356 all undo data in it is removed */
357#define TRX_UNDO_PREPARED 5 /* contains an undo log of an
358 prepared transaction */
360#ifndef UNIV_HOTBACKUP
364struct trx_undo_struct{
365 /*-----------------------------*/
366 ulint id;
368 ulint type;
370 ulint state;
372 ibool del_marks;
382 XID xid;
385 table_id_t table_id;
388 /*-----------------------------*/
389 ulint space;
391 ulint zip_size;
400 ulint size;
401 /*-----------------------------*/
402 ulint empty;
414 /*-----------------------------*/
418};
419#endif /* !UNIV_HOTBACKUP */
420
422#define TRX_UNDO_PAGE_HDR FSEG_PAGE_DATA
423/*-------------------------------------------------------------*/
425/* @{ */
426#define TRX_UNDO_PAGE_TYPE 0
428#define TRX_UNDO_PAGE_START 2
433#define TRX_UNDO_PAGE_FREE 4
436#define TRX_UNDO_PAGE_NODE 6
438/*-------------------------------------------------------------*/
439#define TRX_UNDO_PAGE_HDR_SIZE (6 + FLST_NODE_SIZE)
442/* @} */
443
447
448#define TRX_UNDO_PAGE_REUSE_LIMIT (3 * UNIV_PAGE_SIZE / 4)
449
450/* An update undo log segment may contain several undo logs on its first page
451if the undo logs took so little space that the segment could be cached and
452reused. All the undo log headers are then on the first page, and the last one
453owns the undo log records on subsequent pages if the segment is bigger than
454one page. If an undo log is stored in a segment, then on the first page it is
455allowed to have zero undo records, but if the segment extends to several
456pages, then all the rest of the pages must contain at least one undo log
457record. */
458
461
462#define TRX_UNDO_SEG_HDR (TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE)
464/* @{ */
465/*-------------------------------------------------------------*/
466#define TRX_UNDO_STATE 0
467#define TRX_UNDO_LAST_LOG 2
470#define TRX_UNDO_FSEG_HEADER 4
472#define TRX_UNDO_PAGE_LIST (4 + FSEG_HEADER_SIZE)
476/*-------------------------------------------------------------*/
478#define TRX_UNDO_SEG_HDR_SIZE (4 + FSEG_HEADER_SIZE + FLST_BASE_NODE_SIZE)
479/* @} */
481
484/* @{ */
485/*-------------------------------------------------------------*/
486#define TRX_UNDO_TRX_ID 0
487#define TRX_UNDO_TRX_NO 8
490#define TRX_UNDO_DEL_MARKS 16
494#define TRX_UNDO_LOG_START 18
500#define TRX_UNDO_XID_EXISTS 20
503#define TRX_UNDO_DICT_TRANS 21
510#define TRX_UNDO_TABLE_ID 22
512#define TRX_UNDO_NEXT_LOG 30
514#define TRX_UNDO_PREV_LOG 32
516#define TRX_UNDO_HISTORY_NODE 34
518/*-------------------------------------------------------------*/
520#define TRX_UNDO_LOG_OLD_HDR_SIZE (34 + FLST_NODE_SIZE)
521
522/* Note: the writing of the undo log old header is coded by a log record
523MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE. The appending of an XID to the
524header is logged separately. In this sense, the XID is not really a member
525of the undo log header. TODO: do not append the XID to the log header if XA
526is not needed by the user. The XID wastes about 150 bytes of space in every
527undo log. In the history list we may have millions of undo logs, which means
528quite a large overhead. */
529
531/* @{ */
533#define TRX_UNDO_XA_FORMAT (TRX_UNDO_LOG_OLD_HDR_SIZE)
535#define TRX_UNDO_XA_TRID_LEN (TRX_UNDO_XA_FORMAT + 4)
537#define TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4)
539#define TRX_UNDO_XA_XID (TRX_UNDO_XA_BQUAL_LEN + 4)
540/*--------------------------------------------------------------*/
541#define TRX_UNDO_LOG_XA_HDR_SIZE (TRX_UNDO_XA_XID + XIDDATASIZE)
544/* @} */
545
546#ifndef UNIV_NONINL
547#include "trx0undo.ic"
548#endif
549
550#endif
struct buf_block_struct buf_block_t
Definition buf0types.h:33
#define page_t
Definition page0types.h:35
trx_rseg_t * rseg
Definition trx0undo.h:380
ibool dict_operation
Definition trx0undo.h:377
table_id_t table_id
Definition trx0undo.h:378
undo_no_t top_undo_no
Definition trx0undo.h:404
ulint last_page_no
Definition trx0undo.h:390
ulint top_page_no
Definition trx0undo.h:397
trx_id_t trx_id
Definition trx0undo.h:373
buf_block_t * guess_block
Definition trx0undo.h:405
ulint hdr_page_no
Definition trx0undo.h:386
byte trx_undo_rec_t
Definition trx0types.h:112
ib_id_t undo_no_t
Definition trx0types.h:89
ib_id_t trx_id_t
Definition trx0types.h:85
struct trx_undo_struct trx_undo_t
Definition trx0types.h:52
ib_id_t roll_ptr_t
Definition trx0types.h:87
struct trx_rseg_struct trx_rseg_t
Definition trx0types.h:50
UNIV_INLINE roll_ptr_t trx_read_roll_ptr(const byte *ptr)
UNIV_INTERN byte * trx_undo_parse_page_header(ulint type, byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
Definition trx0undo.cc:701
UNIV_INLINE ibool trx_undo_roll_ptr_is_insert(roll_ptr_t roll_ptr)
UNIV_INTERN ulint trx_undo_assign_undo(trx_t *trx, ulint type)
Definition trx0undo.cc:1739
UNIV_INTERN void trx_undo_update_cleanup(trx_t *trx, page_t *undo_page, mtr_t *mtr)
Definition trx0undo.cc:1900
UNIV_INLINE void trx_write_roll_ptr(byte *ptr, roll_ptr_t roll_ptr)
UNIV_INLINE page_t * trx_undo_page_get_s_latched(ulint space, ulint zip_size, ulint page_no, mtr_t *mtr)
UNIV_INLINE trx_undo_rec_t * trx_undo_page_get_last_rec(page_t *undo_page, ulint page_no, ulint offset)
UNIV_INTERN byte * trx_undo_parse_page_init(byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
Definition trx0undo.cc:360
UNIV_INLINE page_t * trx_undo_page_get(ulint space, ulint zip_size, ulint page_no, mtr_t *mtr)
UNIV_INTERN trx_undo_rec_t * trx_undo_get_prev_rec(trx_undo_rec_t *rec, ulint page_no, ulint offset, mtr_t *mtr)
Definition trx0undo.cc:193
UNIV_INTERN void trx_undo_insert_cleanup(trx_t *trx)
Definition trx0undo.cc:1938
UNIV_INTERN ulint trx_undo_add_page(trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
Definition trx0undo.cc:881
UNIV_INLINE roll_ptr_t trx_undo_build_roll_ptr(ibool is_insert, ulint rseg_id, ulint page_no, ulint offset)
UNIV_INTERN void trx_undo_mem_free(trx_undo_t *undo)
Definition trx0undo.cc:1529
UNIV_INLINE void trx_undo_decode_roll_ptr(roll_ptr_t roll_ptr, ibool *is_insert, ulint *rseg_id, ulint *page_no, ulint *offset)
UNIV_INTERN page_t * trx_undo_set_state_at_finish(trx_undo_t *undo, mtr_t *mtr)
Definition trx0undo.cc:1799
UNIV_INTERN void trx_undo_truncate_start(trx_rseg_t *rseg, ulint space, ulint hdr_page_no, ulint hdr_offset, undo_no_t limit)
Definition trx0undo.cc:1135
UNIV_INLINE trx_undo_rec_t * trx_undo_page_get_prev_rec(trx_undo_rec_t *rec, ulint page_no, ulint offset)
UNIV_INTERN ulint trx_undo_lists_init(trx_rseg_t *rseg)
Definition trx0undo.cc:1382
UNIV_INTERN trx_undo_rec_t * trx_undo_get_next_rec(trx_undo_rec_t *rec, ulint page_no, ulint offset, mtr_t *mtr)
Definition trx0undo.cc:273
UNIV_INTERN page_t * trx_undo_set_state_at_prepare(trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
Definition trx0undo.cc:1850
UNIV_INTERN trx_undo_rec_t * trx_undo_get_first_rec(ulint space, ulint zip_size, ulint page_no, ulint offset, ulint mode, mtr_t *mtr)
Definition trx0undo.cc:304
UNIV_INLINE trx_undo_rec_t * trx_undo_page_get_first_rec(page_t *undo_page, ulint page_no, ulint offset)
UNIV_INTERN void trx_undo_truncate_end(trx_t *trx, trx_undo_t *undo, undo_no_t limit)
Definition trx0undo.cc:1064
UNIV_INTERN byte * trx_undo_parse_discard_latest(byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
Definition trx0undo.cc:817
UNIV_INLINE trx_undo_rec_t * trx_undo_page_get_next_rec(trx_undo_rec_t *rec, ulint page_no, ulint offset)
#define UT_LIST_NODE_T(TYPE)
Definition ut0lst.h:73