1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8 
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation.  The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License, version 2.0, for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
24 
25 *****************************************************************************/
26 
27 /**************************************************//**
28 @file include/trx0undo.h
29 Transaction undo log
30 
31 Created 3/26/1996 Heikki Tuuri
32 *******************************************************/
33 
34 #ifndef trx0undo_h
35 #define trx0undo_h
36 
37 #include "univ.i"
38 #include "trx0types.h"
39 #include "mtr0mtr.h"
40 #include "trx0sys.h"
41 #include "page0types.h"
42 #include "trx0xa.h"
43 
44 #ifndef UNIV_HOTBACKUP
45 /***********************************************************************//**
46 Builds a roll pointer.
47 @return	roll pointer */
48 UNIV_INLINE
49 roll_ptr_t
50 trx_undo_build_roll_ptr(
51 /*====================*/
52 	ibool	is_insert,	/*!< in: TRUE if insert undo log */
53 	ulint	rseg_id,	/*!< in: rollback segment id */
54 	ulint	page_no,	/*!< in: page number */
55 	ulint	offset);	/*!< in: offset of the undo entry within page */
56 /***********************************************************************//**
57 Decodes a roll pointer. */
58 UNIV_INLINE
59 void
60 trx_undo_decode_roll_ptr(
61 /*=====================*/
62 	roll_ptr_t	roll_ptr,	/*!< in: roll pointer */
63 	ibool*		is_insert,	/*!< out: TRUE if insert undo log */
64 	ulint*		rseg_id,	/*!< out: rollback segment id */
65 	ulint*		page_no,	/*!< out: page number */
66 	ulint*		offset);	/*!< out: offset of the undo
67 					entry within page */
68 /***********************************************************************//**
69 Returns TRUE if the roll pointer is of the insert type.
70 @return	TRUE if insert undo log */
71 UNIV_INLINE
72 ibool
73 trx_undo_roll_ptr_is_insert(
74 /*========================*/
75 	roll_ptr_t	roll_ptr);	/*!< in: roll pointer */
76 /***********************************************************************//**
77 Returns true if the record is of the insert type.
78 @return	true if the record was freshly inserted (not updated). */
79 UNIV_INLINE
80 bool
81 trx_undo_trx_id_is_insert(
82 /*======================*/
83 	const byte*	trx_id)	/*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */
84 	MY_ATTRIBUTE((nonnull, pure, warn_unused_result));
85 #endif /* !UNIV_HOTBACKUP */
86 /*****************************************************************//**
87 Writes a roll ptr to an index page. In case that the size changes in
88 some future version, this function should be used instead of
89 mach_write_... */
90 UNIV_INLINE
91 void
92 trx_write_roll_ptr(
93 /*===============*/
94 	byte*		ptr,		/*!< in: pointer to memory where
95 					written */
96 	roll_ptr_t	roll_ptr);	/*!< in: roll ptr */
97 /*****************************************************************//**
98 Reads a roll ptr from an index page. In case that the roll ptr size
99 changes in some future version, this function should be used instead of
100 mach_read_...
101 @return	roll ptr */
102 UNIV_INLINE
103 roll_ptr_t
104 trx_read_roll_ptr(
105 /*==============*/
106 	const byte*	ptr);	/*!< in: pointer to memory from where to read */
107 #ifndef UNIV_HOTBACKUP
108 /******************************************************************//**
109 Gets an undo log page and x-latches it.
110 @return	pointer to page x-latched */
111 UNIV_INLINE
112 page_t*
113 trx_undo_page_get(
114 /*==============*/
115 	ulint	space,		/*!< in: space where placed */
116 	ulint	zip_size,	/*!< in: compressed page size in bytes
117 				or 0 for uncompressed pages */
118 	ulint	page_no,	/*!< in: page number */
119 	mtr_t*	mtr);		/*!< in: mtr */
120 /******************************************************************//**
121 Gets an undo log page and s-latches it.
122 @return	pointer to page s-latched */
123 UNIV_INLINE
124 page_t*
125 trx_undo_page_get_s_latched(
126 /*========================*/
127 	ulint	space,		/*!< in: space where placed */
128 	ulint	zip_size,	/*!< in: compressed page size in bytes
129 				or 0 for uncompressed pages */
130 	ulint	page_no,	/*!< in: page number */
131 	mtr_t*	mtr);		/*!< in: mtr */
132 /******************************************************************//**
133 Returns the previous undo record on the page in the specified log, or
134 NULL if none exists.
135 @return	pointer to record, NULL if none */
136 UNIV_INLINE
137 trx_undo_rec_t*
138 trx_undo_page_get_prev_rec(
139 /*=======================*/
140 	trx_undo_rec_t*	rec,	/*!< in: undo log record */
141 	ulint		page_no,/*!< in: undo log header page number */
142 	ulint		offset);/*!< in: undo log header offset on page */
143 /******************************************************************//**
144 Returns the next undo log record on the page in the specified log, or
145 NULL if none exists.
146 @return	pointer to record, NULL if none */
147 UNIV_INLINE
148 trx_undo_rec_t*
149 trx_undo_page_get_next_rec(
150 /*=======================*/
151 	trx_undo_rec_t*	rec,	/*!< in: undo log record */
152 	ulint		page_no,/*!< in: undo log header page number */
153 	ulint		offset);/*!< in: undo log header offset on page */
154 /******************************************************************//**
155 Returns the last undo record on the page in the specified undo log, or
156 NULL if none exists.
157 @return	pointer to record, NULL if none */
158 UNIV_INLINE
159 trx_undo_rec_t*
160 trx_undo_page_get_last_rec(
161 /*=======================*/
162 	page_t*	undo_page,/*!< in: undo log page */
163 	ulint	page_no,/*!< in: undo log header page number */
164 	ulint	offset);	/*!< in: undo log header offset on page */
165 /******************************************************************//**
166 Returns the first undo record on the page in the specified undo log, or
167 NULL if none exists.
168 @return	pointer to record, NULL if none */
169 UNIV_INLINE
170 trx_undo_rec_t*
171 trx_undo_page_get_first_rec(
172 /*========================*/
173 	page_t*	undo_page,/*!< in: undo log page */
174 	ulint	page_no,/*!< in: undo log header page number */
175 	ulint	offset);/*!< in: undo log header offset on page */
176 /***********************************************************************//**
177 Gets the previous record in an undo log.
178 @return	undo log record, the page s-latched, NULL if none */
179 UNIV_INTERN
180 trx_undo_rec_t*
181 trx_undo_get_prev_rec(
182 /*==================*/
183 	trx_undo_rec_t*	rec,	/*!< in: undo record */
184 	ulint		page_no,/*!< in: undo log header page number */
185 	ulint		offset,	/*!< in: undo log header offset on page */
186 	bool		shared,	/*!< in: true=S-latch, false=X-latch */
187 	mtr_t*		mtr);	/*!< in: mtr */
188 /***********************************************************************//**
189 Gets the next record in an undo log.
190 @return	undo log record, the page s-latched, NULL if none */
191 UNIV_INTERN
192 trx_undo_rec_t*
193 trx_undo_get_next_rec(
194 /*==================*/
195 	trx_undo_rec_t*	rec,	/*!< in: undo record */
196 	ulint		page_no,/*!< in: undo log header page number */
197 	ulint		offset,	/*!< in: undo log header offset on page */
198 	mtr_t*		mtr);	/*!< in: mtr */
199 /***********************************************************************//**
200 Gets the first record in an undo log.
201 @return	undo log record, the page latched, NULL if none */
202 UNIV_INTERN
203 trx_undo_rec_t*
204 trx_undo_get_first_rec(
205 /*===================*/
206 	ulint	space,	/*!< in: undo log header space */
207 	ulint	zip_size,/*!< in: compressed page size in bytes
208 			or 0 for uncompressed pages */
209 	ulint	page_no,/*!< in: undo log header page number */
210 	ulint	offset,	/*!< in: undo log header offset on page */
211 	ulint	mode,	/*!< in: latching mode: RW_S_LATCH or RW_X_LATCH */
212 	mtr_t*	mtr);	/*!< in: mtr */
213 /********************************************************************//**
214 Tries to add a page to the undo log segment where the undo log is placed.
215 @return	X-latched block if success, else NULL */
216 UNIV_INTERN
217 buf_block_t*
218 trx_undo_add_page(
219 /*==============*/
220 	trx_t*		trx,	/*!< in: transaction */
221 	trx_undo_t*	undo,	/*!< in: undo log memory object */
222 	mtr_t*		mtr)	/*!< in: mtr which does not have a latch to any
223 				undo log page; the caller must have reserved
224 				the rollback segment mutex */
225 	MY_ATTRIBUTE((nonnull, warn_unused_result));
226 /********************************************************************//**
227 Frees the last undo log page.
228 The caller must hold the rollback segment mutex. */
229 UNIV_INTERN
230 void
231 trx_undo_free_last_page_func(
232 /*==========================*/
233 #ifdef UNIV_DEBUG
234 	const trx_t*	trx,	/*!< in: transaction */
235 #endif /* UNIV_DEBUG */
236 	trx_undo_t*	undo,	/*!< in/out: undo log memory copy */
237 	mtr_t*		mtr)	/*!< in/out: mini-transaction which does not
238 				have a latch to any undo log page or which
239 				has allocated the undo log page */
240 	MY_ATTRIBUTE((nonnull));
241 #ifdef UNIV_DEBUG
242 # define trx_undo_free_last_page(trx,undo,mtr)	\
243 	trx_undo_free_last_page_func(trx,undo,mtr)
244 #else /* UNIV_DEBUG */
245 # define trx_undo_free_last_page(trx,undo,mtr)	\
246 	trx_undo_free_last_page_func(undo,mtr)
247 #endif /* UNIV_DEBUG */
248 
249 /***********************************************************************//**
250 Truncates an undo log from the end. This function is used during a rollback
251 to free space from an undo log. */
252 UNIV_INTERN
253 void
254 trx_undo_truncate_end_func(
255 /*=======================*/
256 #ifdef UNIV_DEBUG
257 	const trx_t*	trx,	/*!< in: transaction whose undo log it is */
258 #endif /* UNIV_DEBUG */
259 	trx_undo_t*	undo,	/*!< in/out: undo log */
260 	undo_no_t	limit)	/*!< in: all undo records with undo number
261 				>= this value should be truncated */
262 	MY_ATTRIBUTE((nonnull));
263 #ifdef UNIV_DEBUG
264 # define trx_undo_truncate_end(trx,undo,limit)		\
265 	trx_undo_truncate_end_func(trx,undo,limit)
266 #else /* UNIV_DEBUG */
267 # define trx_undo_truncate_end(trx,undo,limit)		\
268 	trx_undo_truncate_end_func(undo,limit)
269 #endif /* UNIV_DEBUG */
270 
271 /***********************************************************************//**
272 Truncates an undo log from the start. This function is used during a purge
273 operation. */
274 UNIV_INTERN
275 void
276 trx_undo_truncate_start(
277 /*====================*/
278 	trx_rseg_t*	rseg,		/*!< in: rollback segment */
279 	ulint		space,		/*!< in: space id of the log */
280 	ulint		hdr_page_no,	/*!< in: header page number */
281 	ulint		hdr_offset,	/*!< in: header offset on the page */
282 	undo_no_t	limit);		/*!< in: all undo pages with
283 					undo numbers < this value
284 					should be truncated; NOTE that
285 					the function only frees whole
286 					pages; the header page is not
287 					freed, but emptied, if all the
288 					records there are < limit */
289 /********************************************************************//**
290 Initializes the undo log lists for a rollback segment memory copy.
291 This function is only called when the database is started or a new
292 rollback segment created.
293 @return	the combined size of undo log segments in pages */
294 UNIV_INTERN
295 ulint
296 trx_undo_lists_init(
297 /*================*/
298 	trx_rseg_t*	rseg);	/*!< in: rollback segment memory object */
299 /**********************************************************************//**
300 Assigns an undo log for a transaction. A new undo log is created or a cached
301 undo log reused.
302 @return DB_SUCCESS if undo log assign successful, possible error codes
303 are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_READ_ONLY
304 DB_OUT_OF_MEMORY */
305 UNIV_INTERN
306 dberr_t
307 trx_undo_assign_undo(
308 /*=================*/
309 	trx_t*		trx,	/*!< in: transaction */
310 	ulint		type)	/*!< in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */
311 	MY_ATTRIBUTE((nonnull, warn_unused_result));
312 /******************************************************************//**
313 Sets the state of the undo log segment at a transaction finish.
314 @return	undo log segment header page, x-latched */
315 UNIV_INTERN
316 page_t*
317 trx_undo_set_state_at_finish(
318 /*=========================*/
319 	trx_undo_t*	undo,	/*!< in: undo log memory copy */
320 	mtr_t*		mtr);	/*!< in: mtr */
321 /******************************************************************//**
322 Sets the state of the undo log segment at a transaction prepare.
323 @return	undo log segment header page, x-latched */
324 UNIV_INTERN
325 page_t*
326 trx_undo_set_state_at_prepare(
327 /*==========================*/
328 	trx_t*		trx,	/*!< in: transaction */
329 	trx_undo_t*	undo,	/*!< in: undo log memory copy */
330 	mtr_t*		mtr);	/*!< in: mtr */
331 
332 /**********************************************************************//**
333 Adds the update undo log header as the first in the history list, and
334 frees the memory object, or puts it to the list of cached update undo log
335 segments. */
336 UNIV_INTERN
337 void
338 trx_undo_update_cleanup(
339 /*====================*/
340 	trx_t*	trx,		/*!< in: trx owning the update undo log */
341 	page_t*	undo_page,	/*!< in: update undo log header page,
342 				x-latched */
343 	mtr_t*	mtr);		/*!< in: mtr */
344 /******************************************************************//**
345 Frees or caches an insert undo log after a transaction commit or rollback.
346 Knowledge of inserts is not needed after a commit or rollback, therefore
347 the data can be discarded. */
348 UNIV_INTERN
349 void
350 trx_undo_insert_cleanup(
351 /*====================*/
352 	trx_t*	trx);	/*!< in: transaction handle */
353 
354 /********************************************************************//**
355 At shutdown, frees the undo logs of a PREPARED transaction. */
356 UNIV_INTERN
357 void
358 trx_undo_free_prepared(
359 /*===================*/
360 	trx_t*	trx)	/*!< in/out: PREPARED transaction */
361 	UNIV_COLD MY_ATTRIBUTE((nonnull));
362 #endif /* !UNIV_HOTBACKUP */
363 /***********************************************************//**
364 Parses the redo log entry of an undo log page initialization.
365 @return	end of log record or NULL */
366 UNIV_INTERN
367 byte*
368 trx_undo_parse_page_init(
369 /*=====================*/
370 	byte*	ptr,	/*!< in: buffer */
371 	byte*	end_ptr,/*!< in: buffer end */
372 	page_t*	page,	/*!< in: page or NULL */
373 	mtr_t*	mtr);	/*!< in: mtr or NULL */
374 /***********************************************************//**
375 Parses the redo log entry of an undo log page header create or reuse.
376 @return	end of log record or NULL */
377 UNIV_INTERN
378 byte*
379 trx_undo_parse_page_header(
380 /*=======================*/
381 	ulint	type,	/*!< in: MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE */
382 	byte*	ptr,	/*!< in: buffer */
383 	byte*	end_ptr,/*!< in: buffer end */
384 	page_t*	page,	/*!< in: page or NULL */
385 	mtr_t*	mtr);	/*!< in: mtr or NULL */
386 /***********************************************************//**
387 Parses the redo log entry of an undo log page header discard.
388 @return	end of log record or NULL */
389 UNIV_INTERN
390 byte*
391 trx_undo_parse_discard_latest(
392 /*==========================*/
393 	byte*	ptr,	/*!< in: buffer */
394 	byte*	end_ptr,/*!< in: buffer end */
395 	page_t*	page,	/*!< in: page or NULL */
396 	mtr_t*	mtr);	/*!< in: mtr or NULL */
397 /************************************************************************
398 Frees an undo log memory copy. */
399 UNIV_INTERN
400 void
401 trx_undo_mem_free(
402 /*==============*/
403 	trx_undo_t*	undo);		/* in: the undo object to be freed */
404 
405 /* Types of an undo log segment */
406 #define	TRX_UNDO_INSERT		1	/* contains undo entries for inserts */
407 #define	TRX_UNDO_UPDATE		2	/* contains undo entries for updates
408 					and delete markings: in short,
409 					modifys (the name 'UPDATE' is a
410 					historical relic) */
411 /* States of an undo log segment */
412 #define TRX_UNDO_ACTIVE		1	/* contains an undo log of an active
413 					transaction */
414 #define	TRX_UNDO_CACHED		2	/* cached for quick reuse */
415 #define	TRX_UNDO_TO_FREE	3	/* insert undo segment can be freed */
416 #define	TRX_UNDO_TO_PURGE	4	/* update undo segment will not be
417 					reused: it can be freed in purge when
418 					all undo data in it is removed */
419 #define	TRX_UNDO_PREPARED	5	/* contains an undo log of an
420 					prepared transaction */
421 
422 #ifndef UNIV_HOTBACKUP
423 /** Transaction undo log memory object; this is protected by the undo_mutex
424 in the corresponding transaction object */
425 
426 struct trx_undo_t{
427 	/*-----------------------------*/
428 	ulint		id;		/*!< undo log slot number within the
429 					rollback segment */
430 	ulint		type;		/*!< TRX_UNDO_INSERT or
431 					TRX_UNDO_UPDATE */
432 	ulint		state;		/*!< state of the corresponding undo log
433 					segment */
434 	ibool		del_marks;	/*!< relevant only in an update undo
435 					log: this is TRUE if the transaction may
436 					have delete marked records, because of
437 					a delete of a row or an update of an
438 					indexed field; purge is then
439 					necessary; also TRUE if the transaction
440 					has updated an externally stored
441 					field */
442 	trx_id_t	trx_id;		/*!< id of the trx assigned to the undo
443 					log */
444 	XID		xid;		/*!< X/Open XA transaction
445 					identification */
446 	ibool		dict_operation;	/*!< TRUE if a dict operation trx */
447 	table_id_t	table_id;	/*!< if a dict operation, then the table
448 					id */
449 	trx_rseg_t*	rseg;		/*!< rseg where the undo log belongs */
450 	/*-----------------------------*/
451 	ulint		space;		/*!< space id where the undo log
452 					placed */
453 	ulint		zip_size;	/*!< compressed page size of space
454 					in bytes, or 0 for uncompressed */
455 	ulint		hdr_page_no;	/*!< page number of the header page in
456 					the undo log */
457 	ulint		hdr_offset;	/*!< header offset of the undo log on
458 				       	the page */
459 	ulint		last_page_no;	/*!< page number of the last page in the
460 					undo log; this may differ from
461 					top_page_no during a rollback */
462 	ulint		size;		/*!< current size in pages */
463 	/*-----------------------------*/
464 	ulint		empty;		/*!< TRUE if the stack of undo log
465 					records is currently empty */
466 	ulint		top_page_no;	/*!< page number where the latest undo
467 					log record was catenated; during
468 					rollback the page from which the latest
469 					undo record was chosen */
470 	ulint		top_offset;	/*!< offset of the latest undo record,
471 					i.e., the topmost element in the undo
472 					log if we think of it as a stack */
473 	undo_no_t	top_undo_no;	/*!< undo number of the latest record */
474 	buf_block_t*	guess_block;	/*!< guess for the buffer block where
475 					the top page might reside */
476 	/*-----------------------------*/
477 	UT_LIST_NODE_T(trx_undo_t) undo_list;
478 					/*!< undo log objects in the rollback
479 					segment are chained into lists */
480 };
481 #endif /* !UNIV_HOTBACKUP */
482 
483 /** The offset of the undo log page header on pages of the undo log */
484 #define	TRX_UNDO_PAGE_HDR	FSEG_PAGE_DATA
485 /*-------------------------------------------------------------*/
486 /** Transaction undo log page header offsets */
487 /* @{ */
488 #define	TRX_UNDO_PAGE_TYPE	0	/*!< TRX_UNDO_INSERT or
489 					TRX_UNDO_UPDATE */
490 #define	TRX_UNDO_PAGE_START	2	/*!< Byte offset where the undo log
491 					records for the LATEST transaction
492 					start on this page (remember that
493 					in an update undo log, the first page
494 					can contain several undo logs) */
495 #define	TRX_UNDO_PAGE_FREE	4	/*!< On each page of the undo log this
496 					field contains the byte offset of the
497 					first free byte on the page */
498 #define TRX_UNDO_PAGE_NODE	6	/*!< The file list node in the chain
499 					of undo log pages */
500 /*-------------------------------------------------------------*/
501 #define TRX_UNDO_PAGE_HDR_SIZE	(6 + FLST_NODE_SIZE)
502 					/*!< Size of the transaction undo
503 					log page header, in bytes */
504 /* @} */
505 
506 /** An update undo segment with just one page can be reused if it has
507 at most this many bytes used; we must leave space at least for one new undo
508 log header on the page */
509 
510 #define TRX_UNDO_PAGE_REUSE_LIMIT	(3 * UNIV_PAGE_SIZE / 4)
511 
512 /* An update undo log segment may contain several undo logs on its first page
513 if the undo logs took so little space that the segment could be cached and
514 reused. All the undo log headers are then on the first page, and the last one
515 owns the undo log records on subsequent pages if the segment is bigger than
516 one page. If an undo log is stored in a segment, then on the first page it is
517 allowed to have zero undo records, but if the segment extends to several
518 pages, then all the rest of the pages must contain at least one undo log
519 record. */
520 
521 /** The offset of the undo log segment header on the first page of the undo
522 log segment */
523 
524 #define	TRX_UNDO_SEG_HDR	(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE)
525 /** Undo log segment header */
526 /* @{ */
527 /*-------------------------------------------------------------*/
528 #define	TRX_UNDO_STATE		0	/*!< TRX_UNDO_ACTIVE, ... */
529 #define	TRX_UNDO_LAST_LOG	2	/*!< Offset of the last undo log header
530 					on the segment header page, 0 if
531 					none */
532 #define	TRX_UNDO_FSEG_HEADER	4	/*!< Header for the file segment which
533 					the undo log segment occupies */
534 #define	TRX_UNDO_PAGE_LIST	(4 + FSEG_HEADER_SIZE)
535 					/*!< Base node for the list of pages in
536 					the undo log segment; defined only on
537 					the undo log segment's first page */
538 /*-------------------------------------------------------------*/
539 /** Size of the undo log segment header */
540 #define TRX_UNDO_SEG_HDR_SIZE	(4 + FSEG_HEADER_SIZE + FLST_BASE_NODE_SIZE)
541 /* @} */
542 
543 
544 /** The undo log header. There can be several undo log headers on the first
545 page of an update undo log segment. */
546 /* @{ */
547 /*-------------------------------------------------------------*/
548 #define	TRX_UNDO_TRX_ID		0	/*!< Transaction id */
549 #define	TRX_UNDO_TRX_NO		8	/*!< Transaction number of the
550 					transaction; defined only if the log
551 					is in a history list */
552 #define TRX_UNDO_DEL_MARKS	16	/*!< Defined only in an update undo
553 					log: TRUE if the transaction may have
554 					done delete markings of records, and
555 					thus purge is necessary */
556 #define	TRX_UNDO_LOG_START	18	/*!< Offset of the first undo log record
557 					of this log on the header page; purge
558 					may remove undo log record from the
559 					log start, and therefore this is not
560 					necessarily the same as this log
561 					header end offset */
562 #define	TRX_UNDO_XID_EXISTS	20	/*!< TRUE if undo log header includes
563 					X/Open XA transaction identification
564 					XID */
565 #define	TRX_UNDO_DICT_TRANS	21	/*!< TRUE if the transaction is a table
566 					create, index create, or drop
567 					transaction: in recovery
568 					the transaction cannot be rolled back
569 					in the usual way: a 'rollback' rather
570 					means dropping the created or dropped
571 					table, if it still exists */
572 #define TRX_UNDO_TABLE_ID	22	/*!< Id of the table if the preceding
573 					field is TRUE */
574 #define	TRX_UNDO_NEXT_LOG	30	/*!< Offset of the next undo log header
575 					on this page, 0 if none */
576 #define	TRX_UNDO_PREV_LOG	32	/*!< Offset of the previous undo log
577 					header on this page, 0 if none */
578 #define TRX_UNDO_HISTORY_NODE	34	/*!< If the log is put to the history
579 					list, the file list node is here */
580 /*-------------------------------------------------------------*/
581 /** Size of the undo log header without XID information */
582 #define TRX_UNDO_LOG_OLD_HDR_SIZE (34 + FLST_NODE_SIZE)
583 
584 /* Note: the writing of the undo log old header is coded by a log record
585 MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE. The appending of an XID to the
586 header is logged separately. In this sense, the XID is not really a member
587 of the undo log header. TODO: do not append the XID to the log header if XA
588 is not needed by the user. The XID wastes about 150 bytes of space in every
589 undo log. In the history list we may have millions of undo logs, which means
590 quite a large overhead. */
591 
592 /** X/Open XA Transaction Identification (XID) */
593 /* @{ */
594 /** xid_t::formatID */
595 #define	TRX_UNDO_XA_FORMAT	(TRX_UNDO_LOG_OLD_HDR_SIZE)
596 /** xid_t::gtrid_length */
597 #define	TRX_UNDO_XA_TRID_LEN	(TRX_UNDO_XA_FORMAT + 4)
598 /** xid_t::bqual_length */
599 #define	TRX_UNDO_XA_BQUAL_LEN	(TRX_UNDO_XA_TRID_LEN + 4)
600 /** Distributed transaction identifier data */
601 #define	TRX_UNDO_XA_XID		(TRX_UNDO_XA_BQUAL_LEN + 4)
602 /*--------------------------------------------------------------*/
603 #define TRX_UNDO_LOG_XA_HDR_SIZE (TRX_UNDO_XA_XID + XIDDATASIZE)
604 					/*!< Total size of the undo log header
605 					with the XA XID */
606 /* @} */
607 
608 #ifndef UNIV_NONINL
609 #include "trx0undo.ic"
610 #endif
611 
612 #endif
613