1
/******************************************************
2
Transaction undo log record
6
Created 3/26/1996 Heikki Tuuri
7
*******************************************************/
13
#include "trx0types.h"
14
#include "row0types.h"
17
#include "dict0types.h"
18
#include "que0types.h"
19
#include "data0data.h"
20
#include "rem0types.h"
22
/***************************************************************************
23
Copies the undo record to the heap. */
28
/* out, own: copy of undo log record */
29
trx_undo_rec_t* undo_rec, /* in: undo log record */
30
mem_heap_t* heap); /* in: heap where copied */
31
/**************************************************************************
32
Reads the undo log record type. */
35
trx_undo_rec_get_type(
36
/*==================*/
37
/* out: record type */
38
trx_undo_rec_t* undo_rec); /* in: undo log record */
39
/**************************************************************************
40
Reads from an undo log record the record compiler info. */
43
trx_undo_rec_get_cmpl_info(
44
/*=======================*/
45
/* out: compiler info */
46
trx_undo_rec_t* undo_rec); /* in: undo log record */
47
/**************************************************************************
48
Returns TRUE if an undo log record contains an extern storage field. */
51
trx_undo_rec_get_extern_storage(
52
/*============================*/
53
/* out: TRUE if extern */
54
trx_undo_rec_t* undo_rec); /* in: undo log record */
55
/**************************************************************************
56
Reads the undo log record number. */
59
trx_undo_rec_get_undo_no(
60
/*=====================*/
62
trx_undo_rec_t* undo_rec); /* in: undo log record */
63
/**************************************************************************
64
* Returns the start of the undo record data area. */
69
/*==================*/
70
/* out: compiler info */
71
trx_undo_rec_t* undo_rec, /* in: undo log record */
72
dulint undo_no); /* in: undo no read from node */
74
/**************************************************************************
75
Reads from an undo log record the general parameters. */
78
trx_undo_rec_get_pars(
79
/*==================*/
80
/* out: remaining part of undo log
81
record after reading these values */
82
trx_undo_rec_t* undo_rec, /* in: undo log record */
83
ulint* type, /* out: undo record type:
84
TRX_UNDO_INSERT_REC, ... */
85
ulint* cmpl_info, /* out: compiler info, relevant only
86
for update type records */
87
ibool* updated_extern, /* out: TRUE if we updated an
88
externally stored fild */
89
dulint* undo_no, /* out: undo log record number */
90
dulint* table_id); /* out: table id */
91
/***********************************************************************
92
Builds a row reference from an undo log record. */
95
trx_undo_rec_get_row_ref(
96
/*=====================*/
97
/* out: pointer to remaining part of undo
99
byte* ptr, /* in: remaining part of a copy of an undo log
100
record, at the start of the row reference;
101
NOTE that this copy of the undo log record must
102
be preserved as long as the row reference is
103
used, as we do NOT copy the data in the
105
dict_index_t* index, /* in: clustered index */
106
dtuple_t** ref, /* out, own: row reference */
107
mem_heap_t* heap); /* in: memory heap from which the memory
108
needed is allocated */
109
/***********************************************************************
110
Skips a row reference from an undo log record. */
113
trx_undo_rec_skip_row_ref(
114
/*======================*/
115
/* out: pointer to remaining part of undo
117
byte* ptr, /* in: remaining part in update undo log
118
record, at the start of the row reference */
119
dict_index_t* index); /* in: clustered index */
120
/**************************************************************************
121
Reads from an undo log update record the system field values of the old
125
trx_undo_update_rec_get_sys_cols(
126
/*=============================*/
127
/* out: remaining part of undo log
128
record after reading these values */
129
byte* ptr, /* in: remaining part of undo log
130
record after reading general
132
dulint* trx_id, /* out: trx id */
133
dulint* roll_ptr, /* out: roll ptr */
134
ulint* info_bits); /* out: info bits state */
135
/***********************************************************************
136
Builds an update vector based on a remaining part of an undo log record. */
139
trx_undo_update_rec_get_update(
140
/*===========================*/
141
/* out: remaining part of the record,
142
NULL if an error detected, which means that
143
the record is corrupted */
144
byte* ptr, /* in: remaining part in update undo log
145
record, after reading the row reference
146
NOTE that this copy of the undo log record must
147
be preserved as long as the update vector is
148
used, as we do NOT copy the data in the
150
dict_index_t* index, /* in: clustered index */
151
ulint type, /* in: TRX_UNDO_UPD_EXIST_REC,
152
TRX_UNDO_UPD_DEL_REC, or
153
TRX_UNDO_DEL_MARK_REC; in the last case,
154
only trx id and roll ptr fields are added to
156
dulint trx_id, /* in: transaction id from this undorecord */
157
dulint roll_ptr,/* in: roll pointer from this undo record */
158
ulint info_bits,/* in: info bits from this undo record */
159
trx_t* trx, /* in: transaction */
160
mem_heap_t* heap, /* in: memory heap from which the memory
161
needed is allocated */
162
upd_t** upd); /* out, own: update vector */
163
/***********************************************************************
164
Builds a partial row from an update undo log record. It contains the
165
columns which occur as ordering in any index of the table. */
168
trx_undo_rec_get_partial_row(
169
/*=========================*/
170
/* out: pointer to remaining part of undo
172
byte* ptr, /* in: remaining part in update undo log
173
record of a suitable type, at the start of
174
the stored index columns;
175
NOTE that this copy of the undo log record must
176
be preserved as long as the partial row is
177
used, as we do NOT copy the data in the
179
dict_index_t* index, /* in: clustered index */
180
dtuple_t** row, /* out, own: partial row */
181
ibool ignore_prefix, /* in: flag to indicate if we
182
expect blob prefixes in undo. Used
183
only in the assertion. */
184
mem_heap_t* heap); /* in: memory heap from which the memory
185
needed is allocated */
186
/***************************************************************************
187
Writes information to an undo log about an insert, update, or a delete marking
188
of a clustered index record. This information is used in a rollback of the
189
transaction and in consistent reads that must look to the history of this
193
trx_undo_report_row_operation(
194
/*==========================*/
195
/* out: DB_SUCCESS or error code */
196
ulint flags, /* in: if BTR_NO_UNDO_LOG_FLAG bit is
198
ulint op_type, /* in: TRX_UNDO_INSERT_OP or
199
TRX_UNDO_MODIFY_OP */
200
que_thr_t* thr, /* in: query thread */
201
dict_index_t* index, /* in: clustered index */
202
const dtuple_t* clust_entry, /* in: in the case of an insert,
203
index entry to insert into the
204
clustered index, otherwise NULL */
205
const upd_t* update, /* in: in the case of an update,
206
the update vector, otherwise NULL */
207
ulint cmpl_info, /* in: compiler info on secondary
209
const rec_t* rec, /* in: case of an update or delete
210
marking, the record in the clustered
211
index, otherwise NULL */
212
dulint* roll_ptr); /* out: rollback pointer to the
213
inserted undo log record,
214
ut_dulint_zero if BTR_NO_UNDO_LOG
215
flag was specified */
216
/**********************************************************************
217
Copies an undo record to heap. This function can be called if we know that
218
the undo log record exists. */
221
trx_undo_get_undo_rec_low(
222
/*======================*/
223
/* out, own: copy of the record */
224
dulint roll_ptr, /* in: roll pointer to record */
225
mem_heap_t* heap); /* in: memory heap where copied */
226
/**********************************************************************
227
Copies an undo record to heap. */
230
trx_undo_get_undo_rec(
231
/*==================*/
232
/* out: DB_SUCCESS, or
233
DB_MISSING_HISTORY if the undo log
234
has been truncated and we cannot
235
fetch the old version; NOTE: the
236
caller must have latches on the
237
clustered index page and purge_view */
238
dulint roll_ptr, /* in: roll pointer to record */
239
dulint trx_id, /* in: id of the trx that generated
240
the roll pointer: it points to an
241
undo log of this transaction */
242
trx_undo_rec_t** undo_rec, /* out, own: copy of the record */
243
mem_heap_t* heap); /* in: memory heap where copied */
244
/***********************************************************************
245
Build a previous version of a clustered index record. This function checks
246
that the caller has a latch on the index page of the clustered index record
247
and an s-latch on the purge_view. This guarantees that the stack of versions
251
trx_undo_prev_version_build(
252
/*========================*/
253
/* out: DB_SUCCESS, or DB_MISSING_HISTORY if
254
the previous version is not >= purge_view,
255
which means that it may have been removed,
256
DB_ERROR if corrupted record */
257
const rec_t* index_rec,/* in: clustered index record in the
259
mtr_t* index_mtr,/* in: mtr which contains the latch to
260
index_rec page and purge_view */
261
const rec_t* rec, /* in: version of a clustered index record */
262
dict_index_t* index, /* in: clustered index */
263
ulint* offsets,/* in: rec_get_offsets(rec, index) */
264
mem_heap_t* heap, /* in: memory heap from which the memory
265
needed is allocated */
266
rec_t** old_vers);/* out, own: previous version, or NULL if
267
rec is the first inserted version, or if
268
history data has been deleted */
269
/***************************************************************
270
Parses a redo log record of adding an undo log record. */
273
trx_undo_parse_add_undo_rec(
274
/*========================*/
275
/* out: end of log record or NULL */
276
byte* ptr, /* in: buffer */
277
byte* end_ptr,/* in: buffer end */
278
page_t* page); /* in: page or NULL */
279
/***************************************************************
280
Parses a redo log record of erasing of an undo page end. */
283
trx_undo_parse_erase_page_end(
284
/*==========================*/
285
/* out: end of log record or NULL */
286
byte* ptr, /* in: buffer */
287
byte* end_ptr,/* in: buffer end */
288
page_t* page, /* in: page or NULL */
289
mtr_t* mtr); /* in: mtr or NULL */
291
/* Types of an undo log record: these have to be smaller than 16, as the
292
compilation info multiplied by 16 is ORed to this value in an undo log
295
#define TRX_UNDO_INSERT_REC 11 /* fresh insert into clustered index */
296
#define TRX_UNDO_UPD_EXIST_REC 12 /* update of a non-delete-marked
298
#define TRX_UNDO_UPD_DEL_REC 13 /* update of a delete marked record to
299
a not delete marked record; also the
300
fields of the record can change */
301
#define TRX_UNDO_DEL_MARK_REC 14 /* delete marking of a record; fields
303
#define TRX_UNDO_CMPL_INFO_MULT 16 /* compilation info is multiplied by
304
this and ORed to the type above */
305
#define TRX_UNDO_UPD_EXTERN 128 /* This bit can be ORed to type_cmpl
306
to denote that we updated external
307
storage fields: used by purge to
308
free the external storage */
310
/* Operation type flags used in trx_undo_report_row_operation */
311
#define TRX_UNDO_INSERT_OP 1
312
#define TRX_UNDO_MODIFY_OP 2
315
#include "trx0rec.ic"