~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty
  • Date: 2008-11-07 05:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: mordred@palanthas.inaugust.com-20081107055115-0275gvq62buzls77
Fixed a decimal sign thing.

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
        mem_heap_t*     heap);  /* in: memory heap from which the memory
 
182
                                needed is allocated */
 
183
/***************************************************************************
 
184
Writes information to an undo log about an insert, update, or a delete marking
 
185
of a clustered index record. This information is used in a rollback of the
 
186
transaction and in consistent reads that must look to the history of this
 
187
transaction. */
 
188
UNIV_INTERN
 
189
ulint
 
190
trx_undo_report_row_operation(
 
191
/*==========================*/
 
192
                                        /* out: DB_SUCCESS or error code */
 
193
        ulint           flags,          /* in: if BTR_NO_UNDO_LOG_FLAG bit is
 
194
                                        set, does nothing */
 
195
        ulint           op_type,        /* in: TRX_UNDO_INSERT_OP or
 
196
                                        TRX_UNDO_MODIFY_OP */
 
197
        que_thr_t*      thr,            /* in: query thread */
 
198
        dict_index_t*   index,          /* in: clustered index */
 
199
        const dtuple_t* clust_entry,    /* in: in the case of an insert,
 
200
                                        index entry to insert into the
 
201
                                        clustered index, otherwise NULL */
 
202
        const upd_t*    update,         /* in: in the case of an update,
 
203
                                        the update vector, otherwise NULL */
 
204
        ulint           cmpl_info,      /* in: compiler info on secondary
 
205
                                        index updates */
 
206
        const rec_t*    rec,            /* in: case of an update or delete
 
207
                                        marking, the record in the clustered
 
208
                                        index, otherwise NULL */
 
209
        dulint*         roll_ptr);      /* out: rollback pointer to the
 
210
                                        inserted undo log record,
 
211
                                        ut_dulint_zero if BTR_NO_UNDO_LOG
 
212
                                        flag was specified */
 
213
/**********************************************************************
 
214
Copies an undo record to heap. This function can be called if we know that
 
215
the undo log record exists. */
 
216
UNIV_INTERN
 
217
trx_undo_rec_t*
 
218
trx_undo_get_undo_rec_low(
 
219
/*======================*/
 
220
                                        /* out, own: copy of the record */
 
221
        dulint          roll_ptr,       /* in: roll pointer to record */
 
222
        mem_heap_t*     heap);          /* in: memory heap where copied */
 
223
/**********************************************************************
 
224
Copies an undo record to heap. */
 
225
UNIV_INTERN
 
226
ulint
 
227
trx_undo_get_undo_rec(
 
228
/*==================*/
 
229
                                        /* out: DB_SUCCESS, or
 
230
                                        DB_MISSING_HISTORY if the undo log
 
231
                                        has been truncated and we cannot
 
232
                                        fetch the old version; NOTE: the
 
233
                                        caller must have latches on the
 
234
                                        clustered index page and purge_view */
 
235
        dulint          roll_ptr,       /* in: roll pointer to record */
 
236
        dulint          trx_id,         /* in: id of the trx that generated
 
237
                                        the roll pointer: it points to an
 
238
                                        undo log of this transaction */
 
239
        trx_undo_rec_t** undo_rec,      /* out, own: copy of the record */
 
240
        mem_heap_t*     heap);          /* in: memory heap where copied */
 
241
/***********************************************************************
 
242
Build a previous version of a clustered index record. This function checks
 
243
that the caller has a latch on the index page of the clustered index record
 
244
and an s-latch on the purge_view. This guarantees that the stack of versions
 
245
is locked. */
 
246
UNIV_INTERN
 
247
ulint
 
248
trx_undo_prev_version_build(
 
249
/*========================*/
 
250
                                /* out: DB_SUCCESS, or DB_MISSING_HISTORY if
 
251
                                the previous version is not >= purge_view,
 
252
                                which means that it may have been removed,
 
253
                                DB_ERROR if corrupted record */
 
254
        const rec_t*    index_rec,/* in: clustered index record in the
 
255
                                index tree */
 
256
        mtr_t*          index_mtr,/* in: mtr which contains the latch to
 
257
                                index_rec page and purge_view */
 
258
        const rec_t*    rec,    /* in: version of a clustered index record */
 
259
        dict_index_t*   index,  /* in: clustered index */
 
260
        ulint*          offsets,/* in: rec_get_offsets(rec, index) */
 
261
        mem_heap_t*     heap,   /* in: memory heap from which the memory
 
262
                                needed is allocated */
 
263
        rec_t**         old_vers);/* out, own: previous version, or NULL if
 
264
                                rec is the first inserted version, or if
 
265
                                history data has been deleted */
 
266
/***************************************************************
 
267
Parses a redo log record of adding an undo log record. */
 
268
UNIV_INTERN
 
269
byte*
 
270
trx_undo_parse_add_undo_rec(
 
271
/*========================*/
 
272
                        /* out: end of log record or NULL */
 
273
        byte*   ptr,    /* in: buffer */
 
274
        byte*   end_ptr,/* in: buffer end */
 
275
        page_t* page);  /* in: page or NULL */
 
276
/***************************************************************
 
277
Parses a redo log record of erasing of an undo page end. */
 
278
UNIV_INTERN
 
279
byte*
 
280
trx_undo_parse_erase_page_end(
 
281
/*==========================*/
 
282
                        /* out: end of log record or NULL */
 
283
        byte*   ptr,    /* in: buffer */
 
284
        byte*   end_ptr,/* in: buffer end */
 
285
        page_t* page,   /* in: page or NULL */
 
286
        mtr_t*  mtr);   /* in: mtr or NULL */
 
287
 
 
288
/* Types of an undo log record: these have to be smaller than 16, as the
 
289
compilation info multiplied by 16 is ORed to this value in an undo log
 
290
record */
 
291
 
 
292
#define TRX_UNDO_INSERT_REC     11      /* fresh insert into clustered index */
 
293
#define TRX_UNDO_UPD_EXIST_REC  12      /* update of a non-delete-marked
 
294
                                        record */
 
295
#define TRX_UNDO_UPD_DEL_REC    13      /* update of a delete marked record to
 
296
                                        a not delete marked record; also the
 
297
                                        fields of the record can change */
 
298
#define TRX_UNDO_DEL_MARK_REC   14      /* delete marking of a record; fields
 
299
                                        do not change */
 
300
#define TRX_UNDO_CMPL_INFO_MULT 16      /* compilation info is multiplied by
 
301
                                        this and ORed to the type above */
 
302
#define TRX_UNDO_UPD_EXTERN     128     /* This bit can be ORed to type_cmpl
 
303
                                        to denote that we updated external
 
304
                                        storage fields: used by purge to
 
305
                                        free the external storage */
 
306
 
 
307
/* Operation type flags used in trx_undo_report_row_operation */
 
308
#define TRX_UNDO_INSERT_OP              1
 
309
#define TRX_UNDO_MODIFY_OP              2
 
310
 
 
311
#ifndef UNIV_NONINL
 
312
#include "trx0rec.ic"
 
313
#endif
 
314
 
 
315
#endif