MySQL 8.0.31
Source Code Documentation
row0undo.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1997, 2022, 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 also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/row0undo.h
28 Row undo
29
30 Created 1/8/1997 Heikki Tuuri
31 *******************************************************/
32
33#ifndef row0undo_h
34#define row0undo_h
35
36#include "btr0pcur.h"
37#include "btr0types.h"
38#include "dict0types.h"
39#include "mtr0mtr.h"
40#include "que0types.h"
41#include "row0types.h"
42#include "trx0sys.h"
43#include "trx0types.h"
44#include "univ.i"
45
46/** Converts an implicit lock on the record to explicit in case of partial
47 rollback.
48@param[in] cursor cursor to record
49@param[in] node undo node */
51
52/** Creates a row undo node to a query graph.
53@param[in] trx transaction
54@param[in] parent parent node, i.e., a thr node
55@param[in] heap memory heap where created
56@param[in] partial_rollback true if partial rollback
57@return undo node */
59 mem_heap_t *heap, bool partial_rollback);
60
61/** Looks for the clustered index record when node has the row reference.
62 The pcur in node is used in the search. If found, stores the row to node,
63 and stores the position of pcur, and detaches it. The pcur must be closed
64 by the caller in any case.
65 @return true if found; NOTE the node->pcur must be closed by the
66 caller, regardless of the return value */
67[[nodiscard]] bool row_undo_search_clust_to_pcur(
68 undo_node_t *node); /*!< in/out: row undo node */
69/** Undoes a row operation in a table. This is a high-level function used
70 in SQL execution graphs.
71 @return query thread to run next or NULL */
72que_thr_t *row_undo_step(que_thr_t *thr); /*!< in: query thread */
73
74/* A single query thread will try to perform the undo for all successive
75versions of a clustered index record, if the transaction has modified it
76several times during the execution which is rolled back. It may happen
77that the task is transferred to another query thread, if the other thread
78is assigned to handle an undo log record in the chain of different versions
79of the record, and the other thread happens to get the x-latch to the
80clustered index record at the right time.
81 If a query thread notices that the clustered index record it is looking
82for is missing, or the roll ptr field in the record does not point to the
83undo log record the thread was assigned to handle, then it gives up the undo
84task for that undo log record, and fetches the next. This situation can occur
85just in the case where the transaction modified the same record several times
86and another thread is currently doing the undo for successive versions of
87that index record. */
88
89/** Execution state of an undo node */
91 UNDO_NODE_FETCH_NEXT = 1, /*!< we should fetch the next
92 undo log record */
93 UNDO_NODE_INSERT, /*!< undo a fresh insert of a
94 row to a table */
95 UNDO_NODE_MODIFY /*!< undo a modify operation
96 (DELETE or UPDATE) on a row
97 of a table */
98};
99
100/** Undo node structure */
102 que_common_t common; /*!< node type: QUE_NODE_UNDO */
103 enum undo_exec state; /*!< node execution state */
104 trx_t *trx; /*!< trx for which undo is done */
105 roll_ptr_t roll_ptr; /*!< roll pointer to undo log record */
106 trx_undo_rec_t *undo_rec; /*!< undo log record */
107 undo_no_t undo_no; /*!< undo number of the record */
108 ulint rec_type; /*!< undo log record type: TRX_UNDO_INSERT_REC,
109 ... */
110 trx_id_t new_trx_id; /*!< trx id to restore to clustered index
111 record */
112 btr_pcur_t pcur; /*!< persistent cursor used in searching the
113 clustered index record */
114 dict_table_t *table; /*!< table where undo is done */
115 ulint cmpl_info; /*!< compiler analysis of an update */
116 upd_t *update; /*!< update vector for a clustered index
117 record */
118 dtuple_t *ref; /*!< row reference to the next row to handle */
119 dtuple_t *row; /*!< a copy (also fields copied to heap) of the
120 row to handle */
121 row_ext_t *ext; /*!< NULL, or prefixes of the externally
122 stored columns of the row */
123 dtuple_t *undo_row; /*!< NULL, or the row after undo */
124 row_ext_t *undo_ext; /*!< NULL, or prefixes of the externally
125 stored columns of undo_row */
126 dict_index_t *index; /*!< the next index whose record should be
127 handled */
128 mem_heap_t *heap; /*!< memory heap used as auxiliary storage for
129 row; this must be emptied after undo is tried
130 on a row */
131 bool partial; /*!< true if partial rollback */
132};
133
134#endif
The index tree persistent cursor.
The index tree general types.
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:314
undo_exec
Execution state of an undo node.
Definition: row0undo.h:90
@ UNDO_NODE_FETCH_NEXT
we should fetch the next undo log record
Definition: row0undo.h:91
@ UNDO_NODE_INSERT
undo a fresh insert of a row to a table
Definition: row0undo.h:93
@ UNDO_NODE_MODIFY
undo a modify operation (DELETE or UPDATE) on a row of a table
Definition: row0undo.h:95
que_thr_t * row_undo_step(que_thr_t *thr)
Undoes a row operation in a table.
Definition: row0undo.cc:346
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:158
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:128
The tree cursor: the definition appears here only for the compiler to know struct size!
Definition: btr0cur.h:667
Definition: btr0pcur.h:98
Data structure for an index.
Definition: dict0mem.h:1021
Data structure for a database table.
Definition: dict0mem.h:1884
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:299
Definition: que0types.h:50
Definition: que0que.h:241
Prefixes of externally stored columns.
Definition: row0ext.h:94
Definition: trx0trx.h:680
Undo node structure.
Definition: row0undo.h:101
ulint rec_type
undo log record type: TRX_UNDO_INSERT_REC, ...
Definition: row0undo.h:108
undo_no_t undo_no
undo number of the record
Definition: row0undo.h:107
dtuple_t * undo_row
NULL, or the row after undo.
Definition: row0undo.h:123
upd_t * update
update vector for a clustered index record
Definition: row0undo.h:116
row_ext_t * ext
NULL, or prefixes of the externally stored columns of the row.
Definition: row0undo.h:121
btr_pcur_t pcur
persistent cursor used in searching the clustered index record
Definition: row0undo.h:112
trx_id_t new_trx_id
trx id to restore to clustered index record
Definition: row0undo.h:110
enum undo_exec state
node execution state
Definition: row0undo.h:103
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:128
dtuple_t * ref
row reference to the next row to handle
Definition: row0undo.h:118
dict_index_t * index
the next index whose record should be handled
Definition: row0undo.h:126
trx_t * trx
trx for which undo is done
Definition: row0undo.h:104
roll_ptr_t roll_ptr
roll pointer to undo log record
Definition: row0undo.h:105
dtuple_t * row
a copy (also fields copied to heap) of the row to handle
Definition: row0undo.h:119
dict_table_t * table
table where undo is done
Definition: row0undo.h:114
trx_undo_rec_t * undo_rec
undo log record
Definition: row0undo.h:106
bool partial
true if partial rollback
Definition: row0undo.h:131
que_common_t common
node type: QUE_NODE_UNDO
Definition: row0undo.h:102
ulint cmpl_info
compiler analysis of an update
Definition: row0undo.h:115
row_ext_t * undo_ext
NULL, or prefixes of the externally stored columns of undo_row.
Definition: row0undo.h:124
Definition: row0upd.h:564
Transaction system.
Transaction system global type definitions.
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:166
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:141
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:137
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:139
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407