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
Reads the undo log record number. */
51
trx_undo_rec_get_undo_no(
52
/*=====================*/
54
trx_undo_rec_t* undo_rec); /* in: undo log record */
55
/**************************************************************************
56
Reads from an undo log record the general parameters. */
59
trx_undo_rec_get_pars(
60
/*==================*/
61
/* out: remaining part of undo log
62
record after reading these values */
63
trx_undo_rec_t* undo_rec, /* in: undo log record */
64
ulint* type, /* out: undo record type:
65
TRX_UNDO_INSERT_REC, ... */
66
ulint* cmpl_info, /* out: compiler info, relevant only
67
for update type records */
68
dulint* undo_no, /* out: undo log record number */
69
dulint* table_id); /* out: table id */
70
/***********************************************************************
71
Builds a row reference from an undo log record. */
74
trx_undo_rec_get_row_ref(
75
/*=====================*/
76
/* out: pointer to remaining part of undo
78
byte* ptr, /* in: remaining part of a copy of an undo log
79
record, at the start of the row reference;
80
NOTE that this copy of the undo log record must
81
be preserved as long as the row reference is
82
used, as we do NOT copy the data in the
84
dict_index_t* index, /* in: clustered index */
85
dtuple_t** ref, /* out, own: row reference */
86
mem_heap_t* heap); /* in: memory heap from which the memory
87
needed is allocated */
88
/***********************************************************************
89
Skips a row reference from an undo log record. */
92
trx_undo_rec_skip_row_ref(
93
/*======================*/
94
/* out: pointer to remaining part of undo
96
byte* ptr, /* in: remaining part in update undo log
97
record, at the start of the row reference */
98
dict_index_t* index); /* in: clustered index */
99
/**************************************************************************
100
Reads from an undo log update record the system field values of the old
104
trx_undo_update_rec_get_sys_cols(
105
/*=============================*/
106
/* out: remaining part of undo log
107
record after reading these values */
108
byte* ptr, /* in: remaining part of undo log
109
record after reading general
111
dulint* trx_id, /* out: trx id */
112
dulint* roll_ptr, /* out: roll ptr */
113
ulint* info_bits); /* out: info bits state */
114
/***********************************************************************
115
Builds an update vector based on a remaining part of an undo log record. */
118
trx_undo_update_rec_get_update(
119
/*===========================*/
120
/* out: remaining part of the record */
121
byte* ptr, /* in: remaining part in update undo log
122
record, after reading the row reference
123
NOTE that this copy of the undo log record must
124
be preserved as long as the update vector is
125
used, as we do NOT copy the data in the
127
dict_index_t* index, /* in: clustered index */
128
ulint type, /* in: TRX_UNDO_UPD_EXIST_REC,
129
TRX_UNDO_UPD_DEL_REC, or
130
TRX_UNDO_DEL_MARK_REC; in the last case,
131
only trx id and roll ptr fields are added to
133
dulint trx_id, /* in: transaction id from this undorecord */
134
dulint roll_ptr,/* in: roll pointer from this undo record */
135
ulint info_bits,/* in: info bits from this undo record */
136
mem_heap_t* heap, /* in: memory heap from which the memory
137
needed is allocated */
138
upd_t** upd); /* out, own: update vector */
139
/***********************************************************************
140
Builds a partial row from an update undo log record. It contains the
141
columns which occur as ordering in any index of the table. */
144
trx_undo_rec_get_partial_row(
145
/*=========================*/
146
/* out: pointer to remaining part of undo
148
byte* ptr, /* in: remaining part in update undo log
149
record of a suitable type, at the start of
150
the stored index columns;
151
NOTE that this copy of the undo log record must
152
be preserved as long as the partial row is
153
used, as we do NOT copy the data in the
155
dict_index_t* index, /* in: clustered index */
156
dtuple_t** row, /* out, own: partial row */
157
mem_heap_t* heap); /* in: memory heap from which the memory
158
needed is allocated */
159
/***************************************************************************
160
Writes information to an undo log about an insert, update, or a delete marking
161
of a clustered index record. This information is used in a rollback of the
162
transaction and in consistent reads that must look to the history of this
166
trx_undo_report_row_operation(
167
/*==========================*/
168
/* out: DB_SUCCESS or error code */
169
ulint flags, /* in: if BTR_NO_UNDO_LOG_FLAG bit is
171
ulint op_type, /* in: TRX_UNDO_INSERT_OP or
172
TRX_UNDO_MODIFY_OP */
173
que_thr_t* thr, /* in: query thread */
174
dict_index_t* index, /* in: clustered index */
175
dtuple_t* clust_entry, /* in: in the case of an insert,
176
index entry to insert into the
177
clustered index, otherwise NULL */
178
upd_t* update, /* in: in the case of an update,
179
the update vector, otherwise NULL */
180
ulint cmpl_info, /* in: compiler info on secondary
182
rec_t* rec, /* in: case of an update or delete
183
marking, the record in the clustered
184
index, otherwise NULL */
185
dulint* roll_ptr); /* out: rollback pointer to the
186
inserted undo log record,
187
ut_dulint_zero if BTR_NO_UNDO_LOG
188
flag was specified */
189
/**********************************************************************
190
Copies an undo record to heap. This function can be called if we know that
191
the undo log record exists. */
194
trx_undo_get_undo_rec_low(
195
/*======================*/
196
/* out, own: copy of the record */
197
dulint roll_ptr, /* in: roll pointer to record */
198
mem_heap_t* heap); /* in: memory heap where copied */
199
/**********************************************************************
200
Copies an undo record to heap. */
203
trx_undo_get_undo_rec(
204
/*==================*/
205
/* out: DB_SUCCESS, or
206
DB_MISSING_HISTORY if the undo log
207
has been truncated and we cannot
208
fetch the old version; NOTE: the
209
caller must have latches on the
210
clustered index page and purge_view */
211
dulint roll_ptr, /* in: roll pointer to record */
212
dulint trx_id, /* in: id of the trx that generated
213
the roll pointer: it points to an
214
undo log of this transaction */
215
trx_undo_rec_t** undo_rec, /* out, own: copy of the record */
216
mem_heap_t* heap); /* in: memory heap where copied */
217
/***********************************************************************
218
Build a previous version of a clustered index record. This function checks
219
that the caller has a latch on the index page of the clustered index record
220
and an s-latch on the purge_view. This guarantees that the stack of versions
224
trx_undo_prev_version_build(
225
/*========================*/
226
/* out: DB_SUCCESS, or DB_MISSING_HISTORY if
227
the previous version is not >= purge_view,
228
which means that it may have been removed */
229
rec_t* index_rec,/* in: clustered index record in the
231
mtr_t* index_mtr,/* in: mtr which contains the latch to
232
index_rec page and purge_view */
233
rec_t* rec, /* in: version of a clustered index record */
234
dict_index_t* index, /* in: clustered index */
235
mem_heap_t* heap, /* in: memory heap from which the memory
236
needed is allocated */
237
rec_t** old_vers);/* out, own: previous version, or NULL if
238
rec is the first inserted version, or if
239
history data has been deleted */
240
/***************************************************************
241
Parses a redo log record of adding an undo log record. */
244
trx_undo_parse_add_undo_rec(
245
/*========================*/
246
/* out: end of log record or NULL */
247
byte* ptr, /* in: buffer */
248
byte* end_ptr,/* in: buffer end */
249
page_t* page); /* in: page or NULL */
250
/***************************************************************
251
Parses a redo log record of erasing of an undo page end. */
254
trx_undo_parse_erase_page_end(
255
/*==========================*/
256
/* out: end of log record or NULL */
257
byte* ptr, /* in: buffer */
258
byte* end_ptr,/* in: buffer end */
259
page_t* page, /* in: page or NULL */
260
mtr_t* mtr); /* in: mtr or NULL */
262
/* Types of an undo log record: these have to be smaller than 16, as the
263
compilation info multiplied by 16 is ORed to this value in an undo log
265
#define TRX_UNDO_INSERT_REC 11 /* fresh insert into clustered index */
266
#define TRX_UNDO_UPD_EXIST_REC 12 /* update of a non-delete-marked
268
#define TRX_UNDO_UPD_DEL_REC 13 /* update of a delete marked record to
269
a not delete marked record; also the
270
fields of the record can change */
271
#define TRX_UNDO_DEL_MARK_REC 14 /* delete marking of a record; fields
273
#define TRX_UNDO_CMPL_INFO_MULT 16 /* compilation info is multiplied by
274
this and ORed to the type above */
276
/* Operation type flags used in trx_undo_report_row_operation */
277
#define TRX_UNDO_INSERT_OP 1
278
#define TRX_UNDO_MODIFY_OP 2
281
#include "trx0rec.ic"