~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

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