1
/*****************************************************************************
3
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/**************************************************//**
1
/******************************************************
23
6
Created 1/8/1997 Heikki Tuuri
24
7
*******************************************************/
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. */
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. */
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 */
134
117
undo_node_t* undo;
136
119
ut_ad(trx && parent && heap);
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));
140
123
undo->common.type = QUE_NODE_UNDO;
141
124
undo->common.parent = parent;
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. */
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
148
undo_node_t* node) /* in: row undo node */
166
150
dict_index_t* clust_index;
185
169
offsets = rec_get_offsets(rec, clust_index, offsets,
186
170
ULINT_UNDEFINED, &heap);
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,
191
176
/* We must remove the reservation on the undo log record
192
177
BEFORE releasing the latch on the clustered index page: this
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
210
/* REDUNDANT and COMPACT formats store a local
211
768-byte prefix of each externally stored
212
column. No cache is needed. */
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,
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. */
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 */
256
ibool locked_data_dict;
226
ibool locked_data_dict;
258
228
ut_ad(node && thr);
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. */
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 */
354
324
undo_node_t* node;