~jaypipes/drizzle/new-test-runner

« back to all changes in this revision

Viewing changes to storage/innobase/include/trx0rec.h

  • Committer: Jay Pipes
  • Date: 2008-12-11 17:52:34 UTC
  • mfrom: (482.16.152 testable)
  • Revision ID: jpipes@serialcoder-20081211175234-uqsfvmgxejvmellq
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Transaction undo log record
 
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
 
6
Created 3/26/1996 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef trx0rec_h
 
10
#define trx0rec_h
 
11
 
 
12
#include "univ.i"
 
13
#include "trx0types.h"
 
14
#include "row0types.h"
 
15
#include "mtr0mtr.h"
 
16
#include "trx0sys.h"
 
17
#include "dict0types.h"
 
18
#include "que0types.h"
 
19
#include "data0data.h"
 
20
#include "rem0types.h"
 
21
 
 
22
/***************************************************************************
 
23
Copies the undo record to the heap. */
 
24
UNIV_INLINE
 
25
trx_undo_rec_t*
 
26
trx_undo_rec_copy(
 
27
/*==============*/
 
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. */
 
33
UNIV_INLINE
 
34
ulint
 
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. */
 
41
UNIV_INLINE
 
42
ulint
 
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. */
 
49
UNIV_INLINE
 
50
ibool
 
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. */
 
57
UNIV_INLINE
 
58
dulint
 
59
trx_undo_rec_get_undo_no(
 
60
/*=====================*/
 
61
                                        /* out: undo no */
 
62
        trx_undo_rec_t* undo_rec);      /* in: undo log record */
 
63
/**************************************************************************
 
64
 * Returns the start of the undo record data area. */
 
65
 
 
66
UNIV_INLINE
 
67
byte*
 
68
trx_undo_rec_get_ptr(
 
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 */
 
73
 
 
74
/**************************************************************************
 
75
Reads from an undo log record the general parameters. */
 
76
UNIV_INTERN
 
77
byte*
 
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. */
 
93
UNIV_INTERN
 
94
byte*
 
95
trx_undo_rec_get_row_ref(
 
96
/*=====================*/
 
97
                                /* out: pointer to remaining part of undo
 
98
                                record */
 
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
 
104
                                record! */
 
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. */
 
111
UNIV_INTERN
 
112
byte*
 
113
trx_undo_rec_skip_row_ref(
 
114
/*======================*/
 
115
                                /* out: pointer to remaining part of undo
 
116
                                record */
 
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
 
122
version. */
 
123
UNIV_INTERN
 
124
byte*
 
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
 
131
                                parameters */
 
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. */
 
137
UNIV_INTERN
 
138
byte*
 
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
 
149
                                record! */
 
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
 
155
                                the update vector */
 
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. */
 
166
UNIV_INTERN
 
167
byte*
 
168
trx_undo_rec_get_partial_row(
 
169
/*=========================*/
 
170
                                /* out: pointer to remaining part of undo
 
171
                                record */
 
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
 
178
                                record! */
 
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
 
190
transaction. */
 
191
UNIV_INTERN
 
192
ulint
 
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
 
197
                                        set, does nothing */
 
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
 
208
                                        index updates */
 
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. */
 
219
UNIV_INTERN
 
220
trx_undo_rec_t*
 
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. */
 
228
UNIV_INTERN
 
229
ulint
 
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
 
248
is locked. */
 
249
UNIV_INTERN
 
250
ulint
 
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
 
258
                                index tree */
 
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. */
 
271
UNIV_INTERN
 
272
byte*
 
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. */
 
281
UNIV_INTERN
 
282
byte*
 
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 */
 
290
 
 
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
 
293
record */
 
294
 
 
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
 
297
                                        record */
 
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
 
302
                                        do not change */
 
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 */
 
309
 
 
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
 
313
 
 
314
#ifndef UNIV_NONINL
 
315
#include "trx0rec.ic"
 
316
#endif
 
317
 
 
318
#endif