30
13
#include "trx0types.h"
31
14
#include "row0types.h"
32
15
#include "mtr0mtr.h"
33
17
#include "dict0types.h"
18
#include "que0types.h"
34
19
#include "data0data.h"
35
20
#include "rem0types.h"
37
#ifndef UNIV_HOTBACKUP
38
# include "que0types.h"
40
/***********************************************************************//**
41
Copies the undo record to the heap.
42
@return own: copy of undo log record */
22
/***************************************************************************
23
Copies the undo record to the heap. */
47
const 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 */
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. */
54
35
trx_undo_rec_get_type(
55
36
/*==================*/
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 */
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. */
62
43
trx_undo_rec_get_cmpl_info(
63
44
/*=======================*/
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 */
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. */
70
51
trx_undo_rec_get_extern_storage(
71
52
/*============================*/
72
const trx_undo_rec_t* undo_rec); /*!< in: undo log record */
73
/**********************************************************************//**
74
Reads the undo log record number.
53
/* out: TRUE if extern */
54
trx_undo_rec_t* undo_rec); /* in: undo log record */
55
/**************************************************************************
56
Reads the undo log record number. */
78
59
trx_undo_rec_get_undo_no(
79
60
/*=====================*/
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 */
62
trx_undo_rec_t* undo_rec); /* in: undo log record */
63
/**************************************************************************
64
* Returns the start of the undo record data area. */
86
trx_undo_rec_get_offset(
87
/*====================*/
88
undo_no_t undo_no) /*!< in: undo no read from node */
89
__attribute__((const));
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))
96
/**********************************************************************//**
97
Reads from an undo log record the general parameters.
98
@return remaining part of undo log record after reading these values */
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. */
101
78
trx_undo_rec_get_pars(
102
79
/*==================*/
103
trx_undo_rec_t* undo_rec, /*!< in: undo log record */
104
ulint* type, /*!< out: undo record type:
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:
105
84
TRX_UNDO_INSERT_REC, ... */
106
ulint* cmpl_info, /*!< out: compiler info, relevant only
85
ulint* cmpl_info, /* out: compiler info, relevant only
107
86
for update type records */
108
ibool* updated_extern, /*!< out: TRUE if we updated an
87
ibool* updated_extern, /* out: TRUE if we updated an
109
88
externally stored fild */
110
undo_no_t* undo_no, /*!< out: undo log record number */
111
table_id_t* 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 */
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. */
117
95
trx_undo_rec_get_row_ref(
118
96
/*=====================*/
119
byte* ptr, /*!< in: remaining part of a copy of an undo log
97
/* out: pointer to remaining part of undo
99
byte* ptr, /* in: remaining part of a copy of an undo log
120
100
record, at the start of the row reference;
121
101
NOTE that this copy of the undo log record must
122
102
be preserved as long as the row reference is
123
103
used, as we do NOT copy the data in the
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
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
128
108
needed is allocated */
129
/*******************************************************************//**
130
Skips a row reference from an undo log record.
131
@return pointer to remaining part of undo record */
109
/***********************************************************************
110
Skips a row reference from an undo log record. */
134
113
trx_undo_rec_skip_row_ref(
135
114
/*======================*/
136
byte* ptr, /*!< in: remaining part in update undo log
115
/* out: pointer to remaining part of undo
117
byte* ptr, /* in: remaining part in update undo log
137
118
record, at the start of the row reference */
138
dict_index_t* index); /*!< in: clustered index */
139
/**********************************************************************//**
119
dict_index_t* index); /* in: clustered index */
120
/**************************************************************************
140
121
Reads from an undo log update record the system field values of the old
142
@return remaining part of undo log record after reading these values */
145
125
trx_undo_update_rec_get_sys_cols(
146
126
/*=============================*/
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 */
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. */
159
139
trx_undo_update_rec_get_update(
160
140
/*===========================*/
161
byte* ptr, /*!< in: remaining part in update undo log
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
162
145
record, after reading the row reference
163
146
NOTE that this copy of the undo log record must
164
147
be preserved as long as the update vector is
165
148
used, as we do NOT copy the data in the
167
dict_index_t* index, /*!< in: clustered index */
168
ulint type, /*!< in: TRX_UNDO_UPD_EXIST_REC,
150
dict_index_t* index, /* in: clustered index */
151
ulint type, /* in: TRX_UNDO_UPD_EXIST_REC,
169
152
TRX_UNDO_UPD_DEL_REC, or
170
153
TRX_UNDO_DEL_MARK_REC; in the last case,
171
154
only trx id and roll ptr fields are added to
172
155
the update vector */
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
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
178
161
needed is allocated */
179
upd_t** upd); /*!< out, own: update vector */
180
/*******************************************************************//**
162
upd_t** upd); /* out, own: update vector */
163
/***********************************************************************
181
164
Builds a partial row from an update undo log record. It contains the
182
columns which occur as ordering in any index of the table.
183
@return pointer to remaining part of undo record */
165
columns which occur as ordering in any index of the table. */
186
168
trx_undo_rec_get_partial_row(
187
169
/*=========================*/
188
byte* ptr, /*!< in: remaining part in update undo log
170
/* out: pointer to remaining part of undo
172
byte* ptr, /* in: remaining part in update undo log
189
173
record of a suitable type, at the start of
190
174
the stored index columns;
191
175
NOTE that this copy of the undo log record must
192
176
be preserved as long as the partial row is
193
177
used, as we do NOT copy the data in the
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
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
198
182
expect blob prefixes in undo. Used
199
183
only in the assertion. */
200
mem_heap_t* heap); /*!< in: memory heap from which the memory
184
mem_heap_t* heap); /* in: memory heap from which the memory
201
185
needed is allocated */
202
/***********************************************************************//**
186
/***************************************************************************
203
187
Writes information to an undo log about an insert, update, or a delete marking
204
188
of a clustered index record. This information is used in a rollback of the
205
189
transaction and in consistent reads that must look to the history of this
207
@return DB_SUCCESS or error code */
210
193
trx_undo_report_row_operation(
211
194
/*==========================*/
212
ulint flags, /*!< in: if BTR_NO_UNDO_LOG_FLAG bit is
195
/* out: DB_SUCCESS or error code */
196
ulint flags, /* in: if BTR_NO_UNDO_LOG_FLAG bit is
213
197
set, does nothing */
214
ulint op_type, /*!< in: TRX_UNDO_INSERT_OP or
198
ulint op_type, /* in: TRX_UNDO_INSERT_OP or
215
199
TRX_UNDO_MODIFY_OP */
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,
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,
219
203
index entry to insert into the
220
204
clustered index, otherwise NULL */
221
const upd_t* update, /*!< in: in the case of an update,
205
const upd_t* update, /* in: in the case of an update,
222
206
the update vector, otherwise NULL */
223
ulint cmpl_info, /*!< in: compiler info on secondary
207
ulint cmpl_info, /* in: compiler info on secondary
225
const rec_t* rec, /*!< in: case of an update or delete
209
const rec_t* rec, /* in: case of an update or delete
226
210
marking, the record in the clustered
227
211
index, otherwise NULL */
228
roll_ptr_t* roll_ptr); /*!< out: rollback pointer to the
212
dulint* roll_ptr); /* out: rollback pointer to the
229
213
inserted undo log record,
214
ut_dulint_zero if BTR_NO_UNDO_LOG
231
215
flag was specified */
232
/******************************************************************//**
216
/**********************************************************************
233
217
Copies an undo record to heap. This function can be called if we know that
234
the undo log record exists.
235
@return own: copy of the record */
218
the undo log record exists. */
238
221
trx_undo_get_undo_rec_low(
239
222
/*======================*/
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.
245
NOTE: the caller must have latches on the clustered index page and
248
@return DB_SUCCESS, or DB_MISSING_HISTORY if the undo log has been
249
truncated and we cannot fetch the old version */
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. */
252
230
trx_undo_get_undo_rec(
253
231
/*==================*/
254
roll_ptr_t roll_ptr, /*!< in: roll pointer to record */
255
trx_id_t trx_id, /*!< in: id of the trx that generated
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
256
240
the roll pointer: it points to an
257
241
undo log of this transaction */
258
trx_undo_rec_t** undo_rec, /*!< out, own: copy of the record */
259
mem_heap_t* heap); /*!< in: memory heap where copied */
260
/*******************************************************************//**
242
trx_undo_rec_t** undo_rec, /* out, own: copy of the record */
243
mem_heap_t* heap); /* in: memory heap where copied */
244
/***********************************************************************
261
245
Build a previous version of a clustered index record. This function checks
262
246
that the caller has a latch on the index page of the clustered index record
263
247
and an s-latch on the purge_view. This guarantees that the stack of versions
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 */
270
251
trx_undo_prev_version_build(
271
252
/*========================*/
272
const rec_t* index_rec,/*!< in: clustered index record in the
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
274
mtr_t* index_mtr,/*!< in: mtr which contains the latch to
259
mtr_t* index_mtr,/* in: mtr which contains the latch to
275
260
index_rec page and purge_view */
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
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
280
265
needed is allocated */
281
rec_t** old_vers);/*!< out, own: previous version, or NULL if
266
rec_t** old_vers);/* out, own: previous version, or NULL if
282
267
rec is the first inserted version, or if
283
268
history data has been deleted */
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 */
269
/***************************************************************
270
Parses a redo log record of adding an undo log record. */
290
273
trx_undo_parse_add_undo_rec(
291
274
/*========================*/
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 */
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. */
300
283
trx_undo_parse_erase_page_end(
301
284
/*==========================*/
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 */
307
#ifndef UNIV_HOTBACKUP
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 */
309
291
/* Types of an undo log record: these have to be smaller than 16, as the
310
292
compilation info multiplied by 16 is ORed to this value in an undo log