Drizzled Public API Documentation

trx0undo.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 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 /**************************************************/
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 /***********************************************************************/
41 UNIV_INLINE
44 /*====================*/
45  ibool is_insert,
46  ulint rseg_id,
47  ulint page_no,
48  ulint offset);
49 /***********************************************************************/
51 UNIV_INLINE
52 void
54 /*=====================*/
55  roll_ptr_t roll_ptr,
56  ibool* is_insert,
57  ulint* rseg_id,
58  ulint* page_no,
59  ulint* offset);
61 /***********************************************************************/
64 UNIV_INLINE
65 ibool
67 /*========================*/
68  roll_ptr_t roll_ptr);
69 #endif /* !UNIV_HOTBACKUP */
70 /*****************************************************************/
74 UNIV_INLINE
75 void
77 /*===============*/
78  byte* ptr,
80  roll_ptr_t roll_ptr);
81 /*****************************************************************/
86 UNIV_INLINE
89 /*==============*/
90  const byte* ptr);
91 #ifndef UNIV_HOTBACKUP
92 /******************************************************************/
95 UNIV_INLINE
96 page_t*
98 /*==============*/
99  ulint space,
100  ulint zip_size,
102  ulint page_no,
103  mtr_t* mtr);
104 /******************************************************************/
107 UNIV_INLINE
108 page_t*
110 /*========================*/
111  ulint space,
112  ulint zip_size,
114  ulint page_no,
115  mtr_t* mtr);
116 /******************************************************************/
120 UNIV_INLINE
123 /*=======================*/
124  trx_undo_rec_t* rec,
125  ulint page_no,
126  ulint offset);
127 /******************************************************************/
131 UNIV_INLINE
134 /*=======================*/
135  trx_undo_rec_t* rec,
136  ulint page_no,
137  ulint offset);
138 /******************************************************************/
142 UNIV_INLINE
145 /*=======================*/
146  page_t* undo_page,
147  ulint page_no,
148  ulint offset);
149 /******************************************************************/
153 UNIV_INLINE
156 /*========================*/
157  page_t* undo_page,
158  ulint page_no,
159  ulint offset);
160 /***********************************************************************/
163 UNIV_INTERN
166 /*==================*/
167  trx_undo_rec_t* rec,
168  ulint page_no,
169  ulint offset,
170  mtr_t* mtr);
171 /***********************************************************************/
174 UNIV_INTERN
177 /*==================*/
178  trx_undo_rec_t* rec,
179  ulint page_no,
180  ulint offset,
181  mtr_t* mtr);
182 /***********************************************************************/
185 UNIV_INTERN
188 /*===================*/
189  ulint space,
190  ulint zip_size,
192  ulint page_no,
193  ulint offset,
194  ulint mode,
195  mtr_t* mtr);
196 /********************************************************************/
199 UNIV_INTERN
200 ulint
202 /*==============*/
203  trx_t* trx,
204  trx_undo_t* undo,
205  mtr_t* mtr);
208 /***********************************************************************/
211 UNIV_INTERN
212 void
214 /*==================*/
215  trx_t* trx,
216  trx_undo_t* undo,
217  undo_no_t limit);
219 /***********************************************************************/
222 UNIV_INTERN
223 void
225 /*====================*/
226  trx_rseg_t* rseg,
227  ulint space,
228  ulint hdr_page_no,
229  ulint hdr_offset,
230  undo_no_t limit);
237 /********************************************************************/
242 UNIV_INTERN
243 ulint
245 /*================*/
246  trx_rseg_t* rseg);
247 /**********************************************************************/
253 UNIV_INTERN
254 ulint
256 /*=================*/
257  trx_t* trx,
258  ulint type);
259 /******************************************************************/
262 UNIV_INTERN
263 page_t*
265 /*=========================*/
266  trx_undo_t* undo,
267  mtr_t* mtr);
268 /******************************************************************/
271 UNIV_INTERN
272 page_t*
274 /*==========================*/
275  trx_t* trx,
276  trx_undo_t* undo,
277  mtr_t* mtr);
279 /**********************************************************************/
283 UNIV_INTERN
284 void
286 /*====================*/
287  trx_t* trx,
288  page_t* undo_page,
290  mtr_t* mtr);
291 /******************************************************************/
295 UNIV_INTERN
296 void
298 /*====================*/
299  trx_t* trx);
300 #endif /* !UNIV_HOTBACKUP */
301 /***********************************************************/
304 UNIV_INTERN
305 byte*
307 /*=====================*/
308  byte* ptr,
309  byte* end_ptr,
310  page_t* page,
311  mtr_t* mtr);
312 /***********************************************************/
315 UNIV_INTERN
316 byte*
318 /*=======================*/
319  ulint type,
320  byte* ptr,
321  byte* end_ptr,
322  page_t* page,
323  mtr_t* mtr);
324 /***********************************************************/
327 UNIV_INTERN
328 byte*
330 /*==========================*/
331  byte* ptr,
332  byte* end_ptr,
333  page_t* page,
334  mtr_t* mtr);
335 /************************************************************************
336 Frees an undo log memory copy. */
337 UNIV_INTERN
338 void
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
364 struct trx_undo_struct{
365  /*-----------------------------*/
366  ulint id;
368  ulint type;
370  ulint state;
372  ibool del_marks;
385  table_id_t table_id;
387  trx_rseg_t* rseg;
388  /*-----------------------------*/
389  ulint space;
391  ulint zip_size;
393  ulint hdr_page_no;
395  ulint hdr_offset;
397  ulint last_page_no;
400  ulint size;
401  /*-----------------------------*/
402  ulint empty;
404  ulint top_page_no;
408  ulint top_offset;
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)
440 
442 /* @} */
443 
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
451 if the undo logs took so little space that the segment could be cached and
452 reused. All the undo log headers are then on the first page, and the last one
453 owns the undo log records on subsequent pages if the segment is bigger than
454 one page. If an undo log is stored in a segment, then on the first page it is
455 allowed to have zero undo records, but if the segment extends to several
456 pages, then all the rest of the pages must contain at least one undo log
457 record. */
458 
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)
473 
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 /*-------------------------------------------------------------*/
519 
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
523 MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE. The appending of an XID to the
524 header is logged separately. In this sense, the XID is not really a member
525 of the undo log header. TODO: do not append the XID to the log header if XA
526 is not needed by the user. The XID wastes about 150 bytes of space in every
527 undo log. In the history list we may have millions of undo logs, which means
528 quite 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)
536 
537 #define TRX_UNDO_XA_BQUAL_LEN (TRX_UNDO_XA_TRID_LEN + 4)
538 
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)
542 
544 /* @} */
545 
546 #ifndef UNIV_NONINL
547 #include "trx0undo.ic"
548 #endif
549 
550 #endif