641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
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., 59 Temple
|
|
15 |
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/row0undo.h
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
Row undo
|
22 |
||
23 |
Created 1/8/1997 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#ifndef row0undo_h
|
|
27 |
#define row0undo_h
|
|
28 |
||
29 |
#include "univ.i" |
|
30 |
#include "mtr0mtr.h" |
|
31 |
#include "trx0sys.h" |
|
32 |
#include "btr0types.h" |
|
33 |
#include "btr0pcur.h" |
|
34 |
#include "dict0types.h" |
|
35 |
#include "trx0types.h" |
|
36 |
#include "que0types.h" |
|
37 |
#include "row0types.h" |
|
38 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
39 |
/********************************************************************//**
|
40 |
Creates a row undo node to a query graph.
|
|
41 |
@return own: undo node */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
42 |
UNIV_INTERN
|
43 |
undo_node_t* |
|
44 |
row_undo_node_create( |
|
45 |
/*=================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
46 |
trx_t* trx, /*!< in: transaction */ |
47 |
que_thr_t* parent, /*!< in: parent node, i.e., a thr node */ |
|
48 |
mem_heap_t* heap); /*!< in: memory heap where created */ |
|
49 |
/***********************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
50 |
Looks for the clustered index record when node has the row reference.
|
51 |
The pcur in node is used in the search. If found, stores the row to node,
|
|
52 |
and stores the position of pcur, and detaches it. The pcur must be closed
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
53 |
by the caller in any case.
|
54 |
@return TRUE if found; NOTE the node->pcur must be closed by the
|
|
55 |
caller, regardless of the return value */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
56 |
UNIV_INTERN
|
57 |
ibool
|
|
58 |
row_undo_search_clust_to_pcur( |
|
59 |
/*==========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
60 |
undo_node_t* node); /*!< in: row undo node */ |
61 |
/***********************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
62 |
Undoes a row operation in a table. This is a high-level function used
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
63 |
in SQL execution graphs.
|
64 |
@return query thread to run next or NULL */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
65 |
UNIV_INTERN
|
66 |
que_thr_t* |
|
67 |
row_undo_step( |
|
68 |
/*==========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
69 |
que_thr_t* thr); /*!< in: query thread */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
70 |
|
71 |
/* A single query thread will try to perform the undo for all successive
|
|
72 |
versions of a clustered index record, if the transaction has modified it
|
|
73 |
several times during the execution which is rolled back. It may happen
|
|
74 |
that the task is transferred to another query thread, if the other thread
|
|
75 |
is assigned to handle an undo log record in the chain of different versions
|
|
76 |
of the record, and the other thread happens to get the x-latch to the
|
|
77 |
clustered index record at the right time.
|
|
78 |
If a query thread notices that the clustered index record it is looking
|
|
79 |
for is missing, or the roll ptr field in the record doed not point to the
|
|
80 |
undo log record the thread was assigned to handle, then it gives up the undo
|
|
81 |
task for that undo log record, and fetches the next. This situation can occur
|
|
82 |
just in the case where the transaction modified the same record several times
|
|
83 |
and another thread is currently doing the undo for successive versions of
|
|
84 |
that index record. */
|
|
85 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
86 |
/** Execution state of an undo node */
|
87 |
enum undo_exec { |
|
88 |
UNDO_NODE_FETCH_NEXT = 1, /*!< we should fetch the next |
|
89 |
undo log record */
|
|
90 |
UNDO_NODE_PREV_VERS, /*!< the roll ptr to previous |
|
91 |
version of a row is stored in
|
|
92 |
node, and undo should be done
|
|
93 |
based on it */
|
|
94 |
UNDO_NODE_INSERT, /*!< undo a fresh insert of a |
|
95 |
row to a table */
|
|
96 |
UNDO_NODE_MODIFY /*!< undo a modify operation |
|
97 |
(DELETE or UPDATE) on a row
|
|
98 |
of a table */
|
|
99 |
};
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
100 |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
101 |
/** Undo node structure */
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
102 |
struct undo_node_struct{ |
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
103 |
que_common_t common; /*!< node type: QUE_NODE_UNDO */ |
104 |
enum undo_exec state; /*!< node execution state */ |
|
105 |
trx_t* trx; /*!< trx for which undo is done */ |
|
106 |
roll_ptr_t roll_ptr;/*!< roll pointer to undo log record */ |
|
107 |
trx_undo_rec_t* undo_rec;/*!< undo log record */ |
|
108 |
undo_no_t undo_no;/*!< undo number of the record */ |
|
109 |
ulint rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC, |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
110 |
... */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
111 |
roll_ptr_t new_roll_ptr; |
112 |
/*!< roll ptr to restore to clustered index
|
|
113 |
record */
|
|
114 |
trx_id_t new_trx_id; /*!< trx id to restore to clustered index |
|
115 |
record */
|
|
116 |
btr_pcur_t pcur; /*!< persistent cursor used in searching the |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
117 |
clustered index record */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
118 |
dict_table_t* table; /*!< table where undo is done */ |
119 |
ulint cmpl_info;/*!< compiler analysis of an update */ |
|
120 |
upd_t* update; /*!< update vector for a clustered index |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
121 |
record */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
122 |
dtuple_t* ref; /*!< row reference to the next row to handle */ |
123 |
dtuple_t* row; /*!< a copy (also fields copied to heap) of the |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
124 |
row to handle */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
125 |
row_ext_t* ext; /*!< NULL, or prefixes of the externally |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
126 |
stored columns of the row */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
127 |
dtuple_t* undo_row;/*!< NULL, or the row after undo */ |
128 |
row_ext_t* undo_ext;/*!< NULL, or prefixes of the externally |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
129 |
stored columns of undo_row */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
130 |
dict_index_t* index; /*!< the next index whose record should be |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
131 |
handled */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
132 |
mem_heap_t* heap; /*!< memory heap used as auxiliary storage for |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
133 |
row; this must be emptied after undo is tried
|
134 |
on a row */
|
|
135 |
};
|
|
136 |
||
137 |
||
138 |
#ifndef UNIV_NONINL
|
|
139 |
#include "row0undo.ic" |
|
140 |
#endif
|
|
141 |
||
142 |
#endif
|