~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/row/row0undo.c

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:24:54 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@bitters-20081218072454-8pnep622damjgqli
Fixed one more my_time thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file row/row0undo.c
 
1
/******************************************************
21
2
Row undo
22
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
23
6
Created 1/8/1997 Heikki Tuuri
24
7
*******************************************************/
25
8
 
120
103
if the stored roll ptr in the undo log points to a trx already (being) purged,
121
104
or if the roll ptr is NULL, i.e., it was a fresh insert. */
122
105
 
123
 
/********************************************************************//**
124
 
Creates a row undo node to a query graph.
125
 
@return own: undo node */
 
106
/************************************************************************
 
107
Creates a row undo node to a query graph. */
126
108
UNIV_INTERN
127
109
undo_node_t*
128
110
row_undo_node_create(
129
111
/*=================*/
130
 
        trx_t*          trx,    /*!< in: transaction */
131
 
        que_thr_t*      parent, /*!< in: parent node, i.e., a thr node */
132
 
        mem_heap_t*     heap)   /*!< in: memory heap where created */
 
112
                                /* out, own: undo node */
 
113
        trx_t*          trx,    /* in: transaction */
 
114
        que_thr_t*      parent, /* in: parent node, i.e., a thr node */
 
115
        mem_heap_t*     heap)   /* in: memory heap where created */
133
116
{
134
117
        undo_node_t*    undo;
135
118
 
136
119
        ut_ad(trx && parent && heap);
137
120
 
138
 
        undo = static_cast<undo_node_t *>(mem_heap_alloc(heap, sizeof(undo_node_t)));
 
121
        undo = mem_heap_alloc(heap, sizeof(undo_node_t));
139
122
 
140
123
        undo->common.type = QUE_NODE_UNDO;
141
124
        undo->common.parent = parent;
150
133
        return(undo);
151
134
}
152
135
 
153
 
/***********************************************************//**
 
136
/***************************************************************
154
137
Looks for the clustered index record when node has the row reference.
155
138
The pcur in node is used in the search. If found, stores the row to node,
156
139
and stores the position of pcur, and detaches it. The pcur must be closed
157
 
by the caller in any case.
158
 
@return TRUE if found; NOTE the node->pcur must be closed by the
159
 
caller, regardless of the return value */
 
140
by the caller in any case. */
160
141
UNIV_INTERN
161
142
ibool
162
143
row_undo_search_clust_to_pcur(
163
144
/*==========================*/
164
 
        undo_node_t*    node)   /*!< in: row undo node */
 
145
                                /* out: TRUE if found; NOTE the node->pcur
 
146
                                must be closed by the caller, regardless of
 
147
                                the return value */
 
148
        undo_node_t*    node)   /* in: row undo node */
165
149
{
166
150
        dict_index_t*   clust_index;
167
151
        ibool           found;
185
169
        offsets = rec_get_offsets(rec, clust_index, offsets,
186
170
                                  ULINT_UNDEFINED, &heap);
187
171
 
188
 
        if (!found || node->roll_ptr
189
 
            != row_get_rec_roll_ptr(rec, clust_index, offsets)) {
 
172
        if (!found || 0 != ut_dulint_cmp(node->roll_ptr,
 
173
                                         row_get_rec_roll_ptr(rec, clust_index,
 
174
                                                              offsets))) {
190
175
 
191
176
                /* We must remove the reservation on the undo log record
192
177
                BEFORE releasing the latch on the clustered index page: this
198
183
 
199
184
                ret = FALSE;
200
185
        } else {
201
 
                row_ext_t**     ext;
202
 
 
203
 
                if (dict_table_get_format(node->table) >= DICT_TF_FORMAT_ZIP) {
204
 
                        /* In DYNAMIC or COMPRESSED format, there is
205
 
                        no prefix of externally stored columns in the
206
 
                        clustered index record. Build a cache of
207
 
                        column prefixes. */
208
 
                        ext = &node->ext;
209
 
                } else {
210
 
                        /* REDUNDANT and COMPACT formats store a local
211
 
                        768-byte prefix of each externally stored
212
 
                        column. No cache is needed. */
213
 
                        ext = NULL;
214
 
                        node->ext = NULL;
215
 
                }
216
 
 
217
186
                node->row = row_build(ROW_COPY_DATA, clust_index, rec,
218
 
                                      offsets, NULL, ext, node->heap);
 
187
                                      offsets, NULL, &node->ext, node->heap);
219
188
                if (node->update) {
220
189
                        node->undo_row = dtuple_copy(node->row, node->heap);
221
190
                        row_upd_replace(node->undo_row, &node->undo_ext,
238
207
        return(ret);
239
208
}
240
209
 
241
 
/***********************************************************//**
 
210
/***************************************************************
242
211
Fetches an undo log record and does the undo for the recorded operation.
243
212
If none left, or a partial rollback completed, returns control to the
244
 
parent node, which is always a query thread node.
245
 
@return DB_SUCCESS if operation successfully completed, else error code */
 
213
parent node, which is always a query thread node. */
246
214
static
247
215
ulint
248
216
row_undo(
249
217
/*=====*/
250
 
        undo_node_t*    node,   /*!< in: row undo node */
251
 
        que_thr_t*      thr)    /*!< in: query thread */
 
218
                                /* out: DB_SUCCESS if operation successfully
 
219
                                completed, else error code */
 
220
        undo_node_t*    node,   /* in: row undo node */
 
221
        que_thr_t*      thr)    /* in: query thread */
252
222
{
253
 
        ulint           err;
254
 
        trx_t*          trx;
255
 
        roll_ptr_t      roll_ptr;
256
 
        ibool           locked_data_dict;
 
223
        ulint   err;
 
224
        trx_t*  trx;
 
225
        dulint  roll_ptr;
 
226
        ibool   locked_data_dict;
257
227
 
258
228
        ut_ad(node && thr);
259
229
 
312
282
 
313
283
        if (locked_data_dict) {
314
284
 
315
 
                row_mysql_freeze_data_dictionary(trx);
 
285
                row_mysql_lock_data_dictionary(trx);
316
286
        }
317
287
 
318
288
        if (node->state == UNDO_NODE_INSERT) {
327
297
 
328
298
        if (locked_data_dict) {
329
299
 
330
 
                row_mysql_unfreeze_data_dictionary(trx);
 
300
                row_mysql_unlock_data_dictionary(trx);
331
301
        }
332
302
 
333
303
        /* Do some cleanup */
340
310
        return(err);
341
311
}
342
312
 
343
 
/***********************************************************//**
 
313
/***************************************************************
344
314
Undoes a row operation in a table. This is a high-level function used
345
 
in SQL execution graphs.
346
 
@return query thread to run next or NULL */
 
315
in SQL execution graphs. */
347
316
UNIV_INTERN
348
317
que_thr_t*
349
318
row_undo_step(
350
319
/*==========*/
351
 
        que_thr_t*      thr)    /*!< in: query thread */
 
320
                                /* out: query thread to run next or NULL */
 
321
        que_thr_t*      thr)    /* in: query thread */
352
322
{
353
323
        ulint           err;
354
324
        undo_node_t*    node;
360
330
 
361
331
        trx = thr_get_trx(thr);
362
332
 
363
 
        node = static_cast<undo_node_t *>(thr->run_node);
 
333
        node = thr->run_node;
364
334
 
365
335
        ut_ad(que_node_get_type(node) == QUE_NODE_UNDO);
366
336