MySQL 8.4.2
Source Code Documentation
row0undo.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1997, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/row0undo.h
29 Row undo
30
31 Created 1/8/1997 Heikki Tuuri
32 *******************************************************/
33
34#ifndef row0undo_h
35#define row0undo_h
36
37#include "btr0pcur.h"
38#include "btr0types.h"
39#include "dict0types.h"
40#include "mtr0mtr.h"
41#include "que0types.h"
42#include "row0types.h"
43#include "trx0sys.h"
44#include "trx0types.h"
45#include "univ.i"
46#include "ut0ut.h"
47
48/** Converts an implicit lock on the record to explicit in case of partial
49 rollback.
50@param[in] cursor cursor to record
51@param[in] node undo node */
53
54/** Creates a row undo node to a query graph.
55@param[in] trx transaction
56@param[in] parent parent node, i.e., a thr node
57@param[in] heap memory heap where created
58@param[in] partial_rollback true if partial rollback
59@return undo node */
61 mem_heap_t *heap, bool partial_rollback);
62
63/** Looks for the clustered index record when node has the row reference.
64 The pcur in node is used in the search. If found, stores the row to node,
65 and stores the position of pcur, and detaches it. The pcur must be closed
66 by the caller in any case.
67 @return true if found; NOTE the node->pcur must be closed by the
68 caller, regardless of the return value */
69[[nodiscard]] bool row_undo_search_clust_to_pcur(
70 undo_node_t *node); /*!< in/out: row undo node */
71/** Undoes a row operation in a table. This is a high-level function used
72 in SQL execution graphs.
73 @return query thread to run next or NULL */
74que_thr_t *row_undo_step(que_thr_t *thr); /*!< in: query thread */
75
76/* A single query thread will try to perform the undo for all successive
77versions of a clustered index record, if the transaction has modified it
78several times during the execution which is rolled back. It may happen
79that the task is transferred to another query thread, if the other thread
80is assigned to handle an undo log record in the chain of different versions
81of the record, and the other thread happens to get the x-latch to the
82clustered index record at the right time.
83 If a query thread notices that the clustered index record it is looking
84for is missing, or the roll ptr field in the record does not point to the
85undo log record the thread was assigned to handle, then it gives up the undo
86task for that undo log record, and fetches the next. This situation can occur
87just in the case where the transaction modified the same record several times
88and another thread is currently doing the undo for successive versions of
89that index record. */
90
91/** Execution state of an undo node */
93 UNDO_NODE_FETCH_NEXT = 1, /*!< we should fetch the next
94 undo log record */
95 UNDO_NODE_INSERT, /*!< undo a fresh insert of a
96 row to a table */
97 UNDO_NODE_MODIFY /*!< undo a modify operation
98 (DELETE or UPDATE) on a row
99 of a table */
101
102/** State of long running undo operation for purpose of writing
103periodic messages to error log */
105 explicit Long_undo_state(const trx_t &);
106 /** timer for printing out log messages for long-running rollbacks */
108
109 /** flag which is set when at least one message is logged */
110 bool have_logged{false};
111
112 /** total number of rows to roll back */
114
115 /** transaction state before rollback */
117};
118
119/** Undo node structure */
121 undo_node_t(trx_t &, que_thr_t *parent, bool partial_rollback);
122 /** node type: QUE_NODE_UNDO */
124
125 /** node execution state */
127
128 /** trx for which undo is done */
130
131 /** roll pointer to undo log record */
133
134 /** undo log record */
136
137 /** undo number of the record */
139
140 /** undo log record type: TRX_UNDO_INSERT_REC, ... */
142
143 /** trx id to restore to clustered index record */
145
146 /**persistent cursor used in searching the clustered index record */
148
149 /** table where undo is done */
151
152 /** compiler analysis of an update */
154
155 /** update vector for a clustered index record */
157
158 /** row reference to the next row to handle */
160
161 /** a copy (also fields copied to heap) of the row to handle */
163
164 /** NULL, or prefixes of the externally stored columns of the row */
166
167 /** NULL, or the row after undo */
169
170 /** NULL, or prefixes of the externally stored columns of undo_row */
172
173 /** the next index whose record should be handled */
175
176 /** memory heap used as auxiliary storage for row;
177 this must be emptied after undo is tried on a row */
179
180 /** true if partial rollback */
182
183 /** state of long-running undo */
185};
186
187#endif
The index tree persistent cursor.
The index tree general types.
Allows to monitor an event processing times, allowing to throttle the processing to one per throttle_...
Definition: ut0ut.h:368
Data dictionary global types.
Mini-transaction buffer.
Query graph global types.
Row operation global types.
void row_convert_impl_to_expl_if_needed(btr_cur_t *cursor, undo_node_t *node)
Converts an implicit lock on the record to explicit in case of partial rollback.
Definition: row0undo.cc:377
undo_exec
Execution state of an undo node.
Definition: row0undo.h:92
@ UNDO_NODE_FETCH_NEXT
we should fetch the next undo log record
Definition: row0undo.h:93
@ UNDO_NODE_INSERT
undo a fresh insert of a row to a table
Definition: row0undo.h:95
@ UNDO_NODE_MODIFY
undo a modify operation (DELETE or UPDATE) on a row of a table
Definition: row0undo.h:97
que_thr_t * row_undo_step(que_thr_t *thr)
Undoes a row operation in a table.
Definition: row0undo.cc:408
undo_node_t * row_undo_node_create(trx_t &trx, que_thr_t *parent, mem_heap_t *heap, bool partial_rollback)
Creates a row undo node to a query graph.
Definition: row0undo.cc:151
bool row_undo_search_clust_to_pcur(undo_node_t *node)
Looks for the clustered index record when node has the row reference.
Definition: row0undo.cc:172
State of long running undo operation for purpose of writing periodic messages to error log.
Definition: row0undo.h:104
Long_undo_state(const trx_t &)
Definition: row0undo.cc:144
bool have_logged
flag which is set when at least one message is logged
Definition: row0undo.h:110
trx_state_t trx_state
transaction state before rollback
Definition: row0undo.h:116
undo_no_t rows_total
total number of rows to roll back
Definition: row0undo.h:113
ib::Throttler throttler
timer for printing out log messages for long-running rollbacks
Definition: row0undo.h:107
The tree cursor: the definition appears here only for the compiler to know struct size!
Definition: btr0cur.h:668
Definition: btr0pcur.h:99
Data structure for an index.
Definition: dict0mem.h:1046
Data structure for a database table.
Definition: dict0mem.h:1909
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:682
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Definition: que0types.h:51
Definition: que0que.h:242
Prefixes of externally stored columns.
Definition: row0ext.h:95
Definition: trx0trx.h:684
Undo node structure.
Definition: row0undo.h:120
ulint rec_type
undo log record type: TRX_UNDO_INSERT_REC, ...
Definition: row0undo.h:141
undo_no_t undo_no
undo number of the record
Definition: row0undo.h:138
dtuple_t * undo_row
NULL, or the row after undo.
Definition: row0undo.h:168
upd_t * update
update vector for a clustered index record
Definition: row0undo.h:156
row_ext_t * ext
NULL, or prefixes of the externally stored columns of the row.
Definition: row0undo.h:165
Long_undo_state long_undo_state
state of long-running undo
Definition: row0undo.h:184
btr_pcur_t pcur
persistent cursor used in searching the clustered index record
Definition: row0undo.h:147
trx_id_t new_trx_id
trx id to restore to clustered index record
Definition: row0undo.h:144
enum undo_exec state
node execution state
Definition: row0undo.h:126
mem_heap_t * heap
memory heap used as auxiliary storage for row; this must be emptied after undo is tried on a row
Definition: row0undo.h:178
dtuple_t * ref
row reference to the next row to handle
Definition: row0undo.h:159
undo_node_t(trx_t &, que_thr_t *parent, bool partial_rollback)
Definition: row0undo.cc:132
dict_index_t * index
the next index whose record should be handled
Definition: row0undo.h:174
roll_ptr_t roll_ptr
roll pointer to undo log record
Definition: row0undo.h:132
trx_t & trx
trx for which undo is done
Definition: row0undo.h:129
dtuple_t * row
a copy (also fields copied to heap) of the row to handle
Definition: row0undo.h:162
dict_table_t * table
table where undo is done
Definition: row0undo.h:150
trx_undo_rec_t * undo_rec
undo log record
Definition: row0undo.h:135
bool partial
true if partial rollback
Definition: row0undo.h:181
que_common_t common
node type: QUE_NODE_UNDO
Definition: row0undo.h:123
ulint cmpl_info
compiler analysis of an update
Definition: row0undo.h:153
row_ext_t * undo_ext
NULL, or prefixes of the externally stored columns of undo_row.
Definition: row0undo.h:171
Definition: row0upd.h:565
Transaction system.
Transaction system global type definitions.
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:167
trx_state_t
Transaction states (trx_t::state)
Definition: trx0types.h:80
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:142
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:140
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406
Various utilities.