~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/trx0rec.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Transaction undo log record
22
23
Created 3/26/1996 Heikki Tuuri
24
*******************************************************/
25
26
#ifndef trx0rec_h
27
#define trx0rec_h
28
29
#include "univ.i"
30
#include "trx0types.h"
31
#include "row0types.h"
32
#include "mtr0mtr.h"
33
#include "dict0types.h"
34
#include "data0data.h"
35
#include "rem0types.h"
36
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
37
#ifndef UNIV_HOTBACKUP
38
# include "que0types.h"
39
40
/***********************************************************************//**
41
Copies the undo record to the heap.
42
@return	own: copy of undo log record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
43
UNIV_INLINE
44
trx_undo_rec_t*
45
trx_undo_rec_copy(
46
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
47
	trx_undo_rec_t*	undo_rec,	/*!< in: undo log record */
48
	mem_heap_t*	heap);		/*!< in: heap where copied */
49
/**********************************************************************//**
50
Reads the undo log record type.
51
@return	record type */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
52
UNIV_INLINE
53
ulint
54
trx_undo_rec_get_type(
55
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
56
	const trx_undo_rec_t*	undo_rec);	/*!< in: undo log record */
57
/**********************************************************************//**
58
Reads from an undo log record the record compiler info.
59
@return	compiler info */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
60
UNIV_INLINE
61
ulint
62
trx_undo_rec_get_cmpl_info(
63
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
64
	const trx_undo_rec_t*	undo_rec);	/*!< in: undo log record */
65
/**********************************************************************//**
66
Returns TRUE if an undo log record contains an extern storage field.
67
@return	TRUE if extern */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
68
UNIV_INLINE
69
ibool
70
trx_undo_rec_get_extern_storage(
71
/*============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
72
	const trx_undo_rec_t*	undo_rec);	/*!< in: undo log record */
73
/**********************************************************************//**
74
Reads the undo log record number.
75
@return	undo no */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
76
UNIV_INLINE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
77
undo_no_t
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
78
trx_undo_rec_get_undo_no(
79
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
80
	const trx_undo_rec_t*	undo_rec);	/*!< in: undo log record */
81
/**********************************************************************//**
82
Returns the start of the undo record data area.
83
@return	offset to the data area */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
84
UNIV_INLINE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
85
ulint
86
trx_undo_rec_get_offset(
87
/*====================*/
88
	undo_no_t	undo_no)	/*!< in: undo no read from node */
89
	__attribute__((const));
90
91
/**********************************************************************//**
92
Returns the start of the undo record data area. */
93
#define trx_undo_rec_get_ptr(undo_rec, undo_no)		\
94
	((undo_rec) + trx_undo_rec_get_offset(undo_no))
95
96
/**********************************************************************//**
97
Reads from an undo log record the general parameters.
98
@return	remaining part of undo log record after reading these values */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
99
UNIV_INTERN
100
byte*
101
trx_undo_rec_get_pars(
102
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
103
	trx_undo_rec_t*	undo_rec,	/*!< in: undo log record */
104
	ulint*		type,		/*!< out: undo record type:
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
105
					TRX_UNDO_INSERT_REC, ... */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
106
	ulint*		cmpl_info,	/*!< out: compiler info, relevant only
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
107
					for update type records */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
108
	ibool*		updated_extern,	/*!< out: TRUE if we updated an
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
109
					externally stored fild */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
110
	undo_no_t*	undo_no,	/*!< out: undo log record number */
111
	dulint*		table_id);	/*!< out: table id */
112
/*******************************************************************//**
113
Builds a row reference from an undo log record.
114
@return	pointer to remaining part of undo record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
115
UNIV_INTERN
116
byte*
117
trx_undo_rec_get_row_ref(
118
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
119
	byte*		ptr,	/*!< in: remaining part of a copy of an undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
120
				record, at the start of the row reference;
121
				NOTE that this copy of the undo log record must
122
				be preserved as long as the row reference is
123
				used, as we do NOT copy the data in the
124
				record! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
125
	dict_index_t*	index,	/*!< in: clustered index */
126
	dtuple_t**	ref,	/*!< out, own: row reference */
127
	mem_heap_t*	heap);	/*!< in: memory heap from which the memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
128
				needed is allocated */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
129
/*******************************************************************//**
130
Skips a row reference from an undo log record.
131
@return	pointer to remaining part of undo record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
132
UNIV_INTERN
133
byte*
134
trx_undo_rec_skip_row_ref(
135
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
136
	byte*		ptr,	/*!< in: remaining part in update undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
137
				record, at the start of the row reference */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
138
	dict_index_t*	index);	/*!< in: clustered index */
139
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
140
Reads from an undo log update record the system field values of the old
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
141
version.
142
@return	remaining part of undo log record after reading these values */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
143
UNIV_INTERN
144
byte*
145
trx_undo_update_rec_get_sys_cols(
146
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
147
	byte*		ptr,		/*!< in: remaining part of undo
148
					log record after reading
149
					general parameters */
150
	trx_id_t*	trx_id,		/*!< out: trx id */
151
	roll_ptr_t*	roll_ptr,	/*!< out: roll ptr */
152
	ulint*		info_bits);	/*!< out: info bits state */
153
/*******************************************************************//**
154
Builds an update vector based on a remaining part of an undo log record.
155
@return remaining part of the record, NULL if an error detected, which
156
means that the record is corrupted */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
157
UNIV_INTERN
158
byte*
159
trx_undo_update_rec_get_update(
160
/*===========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
161
	byte*		ptr,	/*!< in: remaining part in update undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
162
				record, after reading the row reference
163
				NOTE that this copy of the undo log record must
164
				be preserved as long as the update vector is
165
				used, as we do NOT copy the data in the
166
				record! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
167
	dict_index_t*	index,	/*!< in: clustered index */
168
	ulint		type,	/*!< in: TRX_UNDO_UPD_EXIST_REC,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
169
				TRX_UNDO_UPD_DEL_REC, or
170
				TRX_UNDO_DEL_MARK_REC; in the last case,
171
				only trx id and roll ptr fields are added to
172
				the update vector */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
173
	trx_id_t	trx_id,	/*!< in: transaction id from this undorecord */
174
	roll_ptr_t	roll_ptr,/*!< in: roll pointer from this undo record */
175
	ulint		info_bits,/*!< in: info bits from this undo record */
176
	trx_t*		trx,	/*!< in: transaction */
177
	mem_heap_t*	heap,	/*!< in: memory heap from which the memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
178
				needed is allocated */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
179
	upd_t**		upd);	/*!< out, own: update vector */
180
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
181
Builds a partial row from an update undo log record. It contains the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
182
columns which occur as ordering in any index of the table.
183
@return	pointer to remaining part of undo record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
184
UNIV_INTERN
185
byte*
186
trx_undo_rec_get_partial_row(
187
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
188
	byte*		ptr,	/*!< in: remaining part in update undo log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
189
				record of a suitable type, at the start of
190
				the stored index columns;
191
				NOTE that this copy of the undo log record must
192
				be preserved as long as the partial row is
193
				used, as we do NOT copy the data in the
194
				record! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
195
	dict_index_t*	index,	/*!< in: clustered index */
196
	dtuple_t**	row,	/*!< out, own: partial row */
197
	ibool		ignore_prefix, /*!< in: flag to indicate if we
641.2.1 by Monty Taylor
InnoDB Plugin 1.0.2
198
				expect blob prefixes in undo. Used
199
				only in the assertion. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
200
	mem_heap_t*	heap);	/*!< in: memory heap from which the memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
201
				needed is allocated */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
202
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
203
Writes information to an undo log about an insert, update, or a delete marking
204
of a clustered index record. This information is used in a rollback of the
205
transaction and in consistent reads that must look to the history of this
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
206
transaction.
207
@return	DB_SUCCESS or error code */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
208
UNIV_INTERN
209
ulint
210
trx_undo_report_row_operation(
211
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
212
	ulint		flags,		/*!< in: if BTR_NO_UNDO_LOG_FLAG bit is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
213
					set, does nothing */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
214
	ulint		op_type,	/*!< in: TRX_UNDO_INSERT_OP or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
215
					TRX_UNDO_MODIFY_OP */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
216
	que_thr_t*	thr,		/*!< in: query thread */
217
	dict_index_t*	index,		/*!< in: clustered index */
218
	const dtuple_t*	clust_entry,	/*!< in: in the case of an insert,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
219
					index entry to insert into the
220
					clustered index, otherwise NULL */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
221
	const upd_t*	update,		/*!< in: in the case of an update,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
222
					the update vector, otherwise NULL */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
223
	ulint		cmpl_info,	/*!< in: compiler info on secondary
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
224
					index updates */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
225
	const rec_t*	rec,		/*!< in: case of an update or delete
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
226
					marking, the record in the clustered
227
					index, otherwise NULL */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
228
	roll_ptr_t*	roll_ptr);	/*!< out: rollback pointer to the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
229
					inserted undo log record,
230
					ut_dulint_zero if BTR_NO_UNDO_LOG
231
					flag was specified */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
232
/******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
233
Copies an undo record to heap. This function can be called if we know that
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
234
the undo log record exists.
235
@return	own: copy of the record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
236
UNIV_INTERN
237
trx_undo_rec_t*
238
trx_undo_get_undo_rec_low(
239
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
240
	roll_ptr_t	roll_ptr,	/*!< in: roll pointer to record */
241
	mem_heap_t*	heap);		/*!< in: memory heap where copied */
242
/******************************************************************//**
243
Copies an undo record to heap.
244
245
NOTE: the caller must have latches on the clustered index page and
246
purge_view.
247
248
@return DB_SUCCESS, or DB_MISSING_HISTORY if the undo log has been
249
truncated and we cannot fetch the old version */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
250
UNIV_INTERN
251
ulint
252
trx_undo_get_undo_rec(
253
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
254
	roll_ptr_t	roll_ptr,	/*!< in: roll pointer to record */
255
	trx_id_t	trx_id,		/*!< in: id of the trx that generated
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
256
					the roll pointer: it points to an
257
					undo log of this transaction */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
258
	trx_undo_rec_t** undo_rec,	/*!< out, own: copy of the record */
259
	mem_heap_t*	heap);		/*!< in: memory heap where copied */
260
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
261
Build a previous version of a clustered index record. This function checks
262
that the caller has a latch on the index page of the clustered index record
263
and an s-latch on the purge_view. This guarantees that the stack of versions
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
264
is locked.
265
@return DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is
266
earlier than purge_view, which means that it may have been removed,
267
DB_ERROR if corrupted record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
268
UNIV_INTERN
269
ulint
270
trx_undo_prev_version_build(
271
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
272
	const rec_t*	index_rec,/*!< in: clustered index record in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
273
				index tree */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
274
	mtr_t*		index_mtr,/*!< in: mtr which contains the latch to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
275
				index_rec page and purge_view */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
276
	const rec_t*	rec,	/*!< in: version of a clustered index record */
277
	dict_index_t*	index,	/*!< in: clustered index */
278
	ulint*		offsets,/*!< in: rec_get_offsets(rec, index) */
279
	mem_heap_t*	heap,	/*!< in: memory heap from which the memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
280
				needed is allocated */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
281
	rec_t**		old_vers);/*!< out, own: previous version, or NULL if
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
282
				rec is the first inserted version, or if
283
				history data has been deleted */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
284
#endif /* !UNIV_HOTBACKUP */
285
/***********************************************************//**
286
Parses a redo log record of adding an undo log record.
287
@return	end of log record or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
288
UNIV_INTERN
289
byte*
290
trx_undo_parse_add_undo_rec(
291
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
292
	byte*	ptr,	/*!< in: buffer */
293
	byte*	end_ptr,/*!< in: buffer end */
294
	page_t*	page);	/*!< in: page or NULL */
295
/***********************************************************//**
296
Parses a redo log record of erasing of an undo page end.
297
@return	end of log record or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
298
UNIV_INTERN
299
byte*
300
trx_undo_parse_erase_page_end(
301
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
302
	byte*	ptr,	/*!< in: buffer */
303
	byte*	end_ptr,/*!< in: buffer end */
304
	page_t*	page,	/*!< in: page or NULL */
305
	mtr_t*	mtr);	/*!< in: mtr or NULL */
306
307
#ifndef UNIV_HOTBACKUP
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
308
309
/* Types of an undo log record: these have to be smaller than 16, as the
310
compilation info multiplied by 16 is ORed to this value in an undo log
311
record */
312
313
#define	TRX_UNDO_INSERT_REC	11	/* fresh insert into clustered index */
314
#define	TRX_UNDO_UPD_EXIST_REC	12	/* update of a non-delete-marked
315
					record */
316
#define	TRX_UNDO_UPD_DEL_REC	13	/* update of a delete marked record to
317
					a not delete marked record; also the
318
					fields of the record can change */
319
#define	TRX_UNDO_DEL_MARK_REC	14	/* delete marking of a record; fields
320
					do not change */
321
#define	TRX_UNDO_CMPL_INFO_MULT	16	/* compilation info is multiplied by
322
					this and ORed to the type above */
323
#define	TRX_UNDO_UPD_EXTERN	128	/* This bit can be ORed to type_cmpl
324
					to denote that we updated external
325
					storage fields: used by purge to
326
					free the external storage */
327
328
/* Operation type flags used in trx_undo_report_row_operation */
329
#define	TRX_UNDO_INSERT_OP		1
330
#define	TRX_UNDO_MODIFY_OP		2
331
332
#ifndef UNIV_NONINL
333
#include "trx0rec.ic"
334
#endif
335
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
336
#endif /* !UNIV_HOTBACKUP */
337
338
#endif /* trx0rec_h */