1
/******************************************************
6
Created 3/26/1996 Heikki Tuuri
7
*******************************************************/
14
#include "trx0types.h"
18
/***********************************************************************
19
Returns a transaction savepoint taken at this point in time. */
25
trx_t* trx); /* in: transaction */
26
/***********************************************************************
27
Creates an undo number array. */
30
trx_undo_arr_create(void);
31
/*=====================*/
32
/***********************************************************************
33
Frees an undo number array. */
38
trx_undo_arr_t* arr); /* in: undo number array */
39
/***********************************************************************
40
Returns pointer to nth element in an undo number array. */
43
trx_undo_arr_get_nth_info(
44
/*======================*/
45
/* out: pointer to the nth element */
46
trx_undo_arr_t* arr, /* in: undo number array */
47
ulint n); /* in: position */
48
/***************************************************************************
49
Tries truncate the undo logs. */
52
trx_roll_try_truncate(
53
/*==================*/
54
trx_t* trx); /* in: transaction */
55
/************************************************************************
56
Pops the topmost record when the two undo logs of a transaction are seen
57
as a single stack of records ordered by their undo numbers. Inserts the
58
undo number of the popped undo record to the array of currently processed
59
undo numbers in the transaction. When the query thread finishes processing
60
of this undo record, it must be released with trx_undo_rec_release. */
63
trx_roll_pop_top_rec_of_trx(
64
/*========================*/
65
/* out: undo log record copied to heap, NULL
66
if none left, or if the undo number of the
67
top record would be less than the limit */
68
trx_t* trx, /* in: transaction */
69
dulint limit, /* in: least undo number we need */
70
dulint* roll_ptr,/* out: roll pointer to undo record */
71
mem_heap_t* heap); /* in: memory heap where copied */
72
/************************************************************************
73
Reserves an undo log record for a query thread to undo. This should be
74
called if the query thread gets the undo log record not using the pop
80
/* out: TRUE if succeeded */
81
trx_t* trx, /* in: transaction */
82
dulint undo_no);/* in: undo number of the record */
83
/***********************************************************************
84
Releases a reserved undo record. */
89
trx_t* trx, /* in: transaction */
90
dulint undo_no);/* in: undo number */
91
/*************************************************************************
92
Starts a rollback operation. */
97
trx_t* trx, /* in: transaction */
98
trx_sig_t* sig, /* in: signal starting the rollback */
99
que_thr_t** next_thr);/* in/out: next query thread to run;
100
if the value which is passed in is
101
a pointer to a NULL pointer, then the
102
calling function can start running
103
a new query thread */
104
/***********************************************************************
105
Rollback or clean up transactions which have no user session. If the
106
transaction already was committed, then we clean up a possible insert
107
undo log. If the transaction was not yet committed, then we roll it back.
108
Note: this is done in a background thread. */
111
trx_rollback_or_clean_all_without_sess(
112
/*===================================*/
113
/* out: a dummy parameter */
114
void* arg __attribute__((unused)));
115
/* in: a dummy parameter required by
117
/********************************************************************
118
Finishes a transaction rollback. */
121
trx_finish_rollback_off_kernel(
122
/*===========================*/
123
que_t* graph, /* in: undo graph which can now be freed */
124
trx_t* trx, /* in: transaction */
125
que_thr_t** next_thr);/* in/out: next query thread to run;
126
if the value which is passed in is
127
a pointer to a NULL pointer, then the
128
calling function can start running
129
a new query thread; if this parameter is
130
NULL, it is ignored */
131
/********************************************************************
132
Builds an undo 'query' graph for a transaction. The actual rollback is
133
performed by executing this query graph like a query subprocedure call.
134
The reply about the completion of the rollback will be sent by this
138
trx_roll_graph_build(
139
/*=================*/
140
/* out, own: the query graph */
141
trx_t* trx); /* in: trx handle */
142
/*************************************************************************
143
Creates a rollback command node struct. */
148
/* out, own: rollback node struct */
149
mem_heap_t* heap); /* in: mem heap where created */
150
/***************************************************************
151
Performs an execution step for a rollback command node in a query graph. */
156
/* out: query thread to run next, or NULL */
157
que_thr_t* thr); /* in: query thread */
158
/***********************************************************************
159
Rollback a transaction used in MySQL. */
162
trx_rollback_for_mysql(
163
/*===================*/
164
/* out: error code or DB_SUCCESS */
165
trx_t* trx); /* in: transaction handle */
166
/***********************************************************************
167
Rollback the latest SQL statement for MySQL. */
170
trx_rollback_last_sql_stat_for_mysql(
171
/*=================================*/
172
/* out: error code or DB_SUCCESS */
173
trx_t* trx); /* in: transaction handle */
174
/***********************************************************************
175
Rollback a transaction used in MySQL. */
178
trx_general_rollback_for_mysql(
179
/*===========================*/
180
/* out: error code or DB_SUCCESS */
181
trx_t* trx, /* in: transaction handle */
182
ibool partial,/* in: TRUE if partial rollback requested */
183
trx_savept_t* savept);/* in: pointer to savepoint undo number, if
184
partial rollback requested */
185
/***********************************************************************
186
Rolls back a transaction back to a named savepoint. Modifications after the
187
savepoint are undone but InnoDB does NOT release the corresponding locks
188
which are stored in memory. If a lock is 'implicit', that is, a new inserted
189
row holds a lock where the lock information is carried by the trx id stored in
190
the row, these locks are naturally released in the rollback. Savepoints which
191
were set after this savepoint are deleted. */
194
trx_rollback_to_savepoint_for_mysql(
195
/*================================*/
196
/* out: if no savepoint
197
of the name found then
199
otherwise DB_SUCCESS */
200
trx_t* trx, /* in: transaction handle */
201
const char* savepoint_name, /* in: savepoint name */
202
ib_longlong* mysql_binlog_cache_pos);/* out: the MySQL binlog cache
203
position corresponding to this
204
savepoint; MySQL needs this
205
information to remove the
206
binlog entries of the queries
207
executed after the savepoint */
208
/***********************************************************************
209
Creates a named savepoint. If the transaction is not yet started, starts it.
210
If there is already a savepoint of the same name, this call erases that old
211
savepoint and replaces it with a new. Savepoints are deleted in a transaction
212
commit or rollback. */
215
trx_savepoint_for_mysql(
216
/*====================*/
217
/* out: always DB_SUCCESS */
218
trx_t* trx, /* in: transaction handle */
219
const char* savepoint_name, /* in: savepoint name */
220
ib_longlong binlog_cache_pos); /* in: MySQL binlog cache
221
position corresponding to this
222
connection at the time of the
225
/***********************************************************************
226
Releases a named savepoint. Savepoints which
227
were set after this savepoint are deleted. */
230
trx_release_savepoint_for_mysql(
231
/*============================*/
232
/* out: if no savepoint
233
of the name found then
235
otherwise DB_SUCCESS */
236
trx_t* trx, /* in: transaction handle */
237
const char* savepoint_name); /* in: savepoint name */
239
/***********************************************************************
240
Frees savepoint structs. */
243
trx_roll_savepoints_free(
244
/*=====================*/
245
trx_t* trx, /* in: transaction handle */
246
trx_named_savept_t* savep); /* in: free all savepoints > this one;
247
if this is NULL, free all savepoints
250
extern sess_t* trx_dummy_sess;
252
/* A cell in the array used during a rollback and a purge */
253
struct trx_undo_inf_struct{
254
dulint trx_no; /* transaction number: not defined during
256
dulint undo_no; /* undo number of an undo record */
257
ibool in_use; /* TRUE if the cell is in use */
260
/* During a rollback and a purge, undo numbers of undo records currently being
261
processed are stored in this array */
263
struct trx_undo_arr_struct{
264
ulint n_cells; /* number of cells in the array */
265
ulint n_used; /* number of cells currently in use */
266
trx_undo_inf_t* infos; /* the array of undo infos */
267
mem_heap_t* heap; /* memory heap from which allocated */
270
/* Rollback command node in a query graph */
271
struct roll_node_struct{
272
que_common_t common; /* node type: QUE_NODE_ROLLBACK */
273
ulint state; /* node execution state */
274
ibool partial;/* TRUE if we want a partial rollback */
275
trx_savept_t savept; /* savepoint to which to roll back, in the
276
case of a partial rollback */
279
/* A savepoint set with SQL's "SAVEPOINT savepoint_id" command */
280
struct trx_named_savept_struct{
281
char* name; /* savepoint name */
282
trx_savept_t savept; /* the undo number corresponding to
284
ib_longlong mysql_binlog_cache_pos;
285
/* the MySQL binlog cache position
286
corresponding to this savepoint, not
287
defined if the MySQL binlogging is not
289
UT_LIST_NODE_T(trx_named_savept_t)
290
trx_savepoints; /* the list of savepoints of a
294
/* Rollback node states */
295
#define ROLL_NODE_SEND 1
296
#define ROLL_NODE_WAIT 2
299
#include "trx0roll.ic"