30
13
#include "trx0types.h"
31
#include "dict0types.h"
32
#ifndef UNIV_HOTBACKUP
33
14
#include "lock0types.h"
34
15
#include "usr0types.h"
35
16
#include "que0types.h"
36
17
#include "mem0mem.h"
37
18
#include "read0types.h"
19
#include "dict0types.h"
38
20
#include "trx0xa.h"
39
21
#include "ut0vec.h"
41
namespace drizzled { class Session; }
43
/** Dummy session used currently in MySQL interface */
23
/* Dummy session used currently in MySQL interface */
44
24
extern sess_t* trx_dummy_sess;
46
/** Number of transactions currently allocated for MySQL: protected by
26
/* Number of transactions currently allocated for MySQL: protected by
47
27
the kernel mutex */
48
28
extern ulint trx_n_mysql_transactions;
50
/********************************************************************//**
30
/*****************************************************************
31
Resets the new record lock info in a transaction struct. */
34
trx_reset_new_rec_lock_info(
35
/*========================*/
36
trx_t* trx); /* in: transaction struct */
37
/*****************************************************************
38
Registers that we have set a new record lock on an index. We only have space
39
to store 2 indexes! If this is called to store more than 2 indexes after
40
trx_reset_new_rec_lock_info(), then this function does nothing. */
43
trx_register_new_rec_lock(
44
/*======================*/
45
trx_t* trx, /* in: transaction struct */
46
dict_index_t* index); /* in: trx sets a new record lock on this
48
/*****************************************************************
49
Checks if trx has set a new record lock on an index. */
52
trx_new_rec_locks_contain(
53
/*======================*/
54
/* out: TRUE if trx has set a new record lock
56
trx_t* trx, /* in: transaction struct */
57
dict_index_t* index); /* in: index */
58
/************************************************************************
51
59
Releases the search latch if trx has reserved it. */
54
62
trx_search_latch_release_if_reserved(
55
63
/*=================================*/
56
trx_t* trx); /*!< in: transaction */
57
/******************************************************************//**
64
trx_t* trx); /* in: transaction */
65
/**********************************************************************
58
66
Set detailed error message for the transaction. */
61
69
trx_set_detailed_error(
62
70
/*===================*/
63
trx_t* trx, /*!< in: transaction struct */
64
const char* msg); /*!< in: detailed error message */
65
/*************************************************************//**
71
trx_t* trx, /* in: transaction struct */
72
const char* msg); /* in: detailed error message */
73
/*****************************************************************
66
74
Set detailed error message for the transaction from a file. Note that the
67
75
file is rewinded before reading from it. */
70
78
trx_set_detailed_error_from_file(
71
79
/*=============================*/
72
trx_t* trx, /*!< in: transaction struct */
73
FILE* file); /*!< in: file to read message from */
74
/****************************************************************//**
75
Checks if the commit id should be logged to the sys header file
76
@return TRUE if the commit id should be logged */
81
const trx_t* trx); /*!< in: trx object */
82
/****************************************************************//**
83
Retrieves the error_info field from a trx.
84
@return the error info */
80
trx_t* trx, /* in: transaction struct */
81
FILE* file); /* in: file to read message from */
82
/********************************************************************
83
Retrieves the error_info field from a trx. */
86
85
const dict_index_t*
87
86
trx_get_error_info(
88
87
/*===============*/
89
const trx_t* trx); /*!< in: trx object */
90
/****************************************************************//**
91
Creates and initializes a transaction object.
92
@return own: the transaction */
88
/* out: the error info */
89
const trx_t* trx); /* in: trx object */
90
/********************************************************************
91
Creates and initializes a transaction object. */
97
sess_t* sess) /*!< in: session */
96
/* out, own: the transaction */
97
sess_t* sess) /* in: session */
98
98
__attribute__((nonnull));
99
/********************************************************************//**
100
Creates a transaction object for MySQL.
101
@return own: transaction object */
99
/************************************************************************
100
Creates a transaction object for MySQL. */
104
103
trx_allocate_for_mysql(void);
105
104
/*========================*/
106
/********************************************************************//**
107
Creates a transaction object for background operations by the master thread.
108
@return own: transaction object */
105
/* out, own: transaction object */
106
/************************************************************************
107
Creates a transaction object for background operations by the master thread. */
111
110
trx_allocate_for_background(void);
112
111
/*=============================*/
113
/********************************************************************//**
112
/* out, own: transaction object */
113
/************************************************************************
114
114
Frees a transaction object. */
119
trx_t* trx); /*!< in, own: trx object */
120
/********************************************************************//**
119
trx_t* trx); /* in, own: trx object */
120
/************************************************************************
121
121
Frees a transaction object for MySQL. */
124
124
trx_free_for_mysql(
125
125
/*===============*/
126
trx_t* trx); /*!< in, own: trx object */
127
/********************************************************************//**
126
trx_t* trx); /* in, own: trx object */
127
/************************************************************************
128
128
Frees a transaction object of a background operation of the master thread. */
131
131
trx_free_for_background(
132
132
/*====================*/
133
trx_t* trx); /*!< in, own: trx object */
134
/****************************************************************//**
133
trx_t* trx); /* in, own: trx object */
134
/********************************************************************
135
135
Creates trx objects for transactions and initializes the trx list of
136
136
trx_sys at database start. Rollback segment and undo log lists must
137
137
already exist when this function is called, because the lists of
142
142
trx_lists_init_at_db_start(void);
143
143
/*============================*/
144
/****************************************************************//**
145
Starts a new transaction.
146
@return TRUE if success, FALSE if the rollback segment could not
147
support this many transactions */
144
/********************************************************************
145
Starts a new transaction. */
152
trx_t* trx, /*!< in: transaction */
153
ulint rseg_id);/*!< in: rollback segment id; if ULINT_UNDEFINED
150
/* out: TRUE if success, FALSE if the rollback
151
segment could not support this many transactions */
152
trx_t* trx, /* in: transaction */
153
ulint rseg_id);/* in: rollback segment id; if ULINT_UNDEFINED
154
154
is passed, the system chooses the rollback segment
155
155
automatically in a round-robin fashion */
156
/****************************************************************//**
157
Starts a new transaction.
156
/********************************************************************
157
Starts a new transaction. */
163
trx_t* trx, /*!< in: transaction */
164
ulint rseg_id);/*!< in: rollback segment id; if ULINT_UNDEFINED
163
trx_t* trx, /* in: transaction */
164
ulint rseg_id);/* in: rollback segment id; if ULINT_UNDEFINED
165
165
is passed, the system chooses the rollback segment
166
166
automatically in a round-robin fashion */
167
/*************************************************************//**
167
/*****************************************************************
168
168
Starts the transaction if it is not yet started. */
171
171
trx_start_if_not_started(
172
172
/*=====================*/
173
trx_t* trx); /*!< in: transaction */
174
/*************************************************************//**
173
trx_t* trx); /* in: transaction */
174
/*****************************************************************
175
175
Starts the transaction if it is not yet started. Assumes we have reserved
176
176
the kernel mutex! */
179
179
trx_start_if_not_started_low(
180
180
/*=========================*/
181
trx_t* trx); /*!< in: transaction */
182
/****************************************************************//**
181
trx_t* trx); /* in: transaction */
182
/********************************************************************
183
183
Commits a transaction. */
186
186
trx_commit_off_kernel(
187
187
/*==================*/
188
trx_t* trx); /*!< in: transaction */
189
/****************************************************************//**
188
trx_t* trx); /* in: transaction */
189
/********************************************************************
190
190
Cleans up a transaction at database startup. The cleanup is needed if
191
191
the transaction already got to the middle of a commit when the database
192
crashed, and we cannot roll it back. */
192
crashed, andf we cannot roll it back. */
195
195
trx_cleanup_at_db_startup(
196
196
/*======================*/
197
trx_t* trx); /*!< in: transaction */
198
/**********************************************************************//**
199
Does the transaction commit for MySQL.
200
@return DB_SUCCESS or error number */
197
trx_t* trx); /* in: transaction */
198
/**************************************************************************
199
Does the transaction commit for MySQL. */
203
202
trx_commit_for_mysql(
204
203
/*=================*/
205
trx_t* trx); /*!< in: trx handle */
206
/**********************************************************************//**
207
Does the transaction prepare for MySQL.
208
@return 0 or error number */
204
/* out: DB_SUCCESS or error number */
205
trx_t* trx); /* in: trx handle */
206
/**************************************************************************
207
Does the transaction prepare for MySQL. */
211
210
trx_prepare_for_mysql(
212
211
/*==================*/
213
trx_t* trx); /*!< in: trx handle */
214
/**********************************************************************//**
212
/* out: 0 or error number */
213
trx_t* trx); /* in: trx handle */
214
/**************************************************************************
215
215
This function is used to find number of prepared transactions and
216
their transaction objects for a recovery.
217
@return number of prepared transactions */
216
their transaction objects for a recovery. */
220
219
trx_recover_for_mysql(
221
220
/*==================*/
222
XID* xid_list, /*!< in/out: prepared transactions */
223
ulint len); /*!< in: number of slots in xid_list */
224
/*******************************************************************//**
221
/* out: number of prepared transactions */
222
XID* xid_list, /* in/out: prepared transactions */
223
ulint len); /* in: number of slots in xid_list */
224
/***********************************************************************
225
225
This function is used to find one X/Open XA distributed transaction
226
which is in the prepared state
227
@return trx or NULL */
226
which is in the prepared state */
230
229
trx_get_trx_by_xid(
231
230
/*===============*/
232
XID* xid); /*!< in: X/Open XA transaction identification */
233
/**********************************************************************//**
231
/* out: trx or NULL */
232
XID* xid); /* in: X/Open XA transaction identification */
233
/**************************************************************************
234
234
If required, flushes the log to disk if we called trx_commit_for_mysql()
235
with trx->flush_log_later == TRUE.
236
@return 0 or error number */
235
with trx->flush_log_later == TRUE. */
239
238
trx_commit_complete_for_mysql(
240
239
/*==========================*/
241
trx_t* trx); /*!< in: trx handle */
242
/**********************************************************************//**
240
/* out: 0 or error number */
241
trx_t* trx); /* in: trx handle */
242
/**************************************************************************
243
243
Marks the latest SQL statement ended. */
246
246
trx_mark_sql_stat_end(
247
247
/*==================*/
248
trx_t* trx); /*!< in: trx handle */
249
/********************************************************************//**
248
trx_t* trx); /* in: trx handle */
249
/************************************************************************
250
250
Assigns a read view for a consistent read query. All the consistent reads
251
251
within the same transaction will get the same read view, which is created
252
when this function is first called for a new started transaction.
253
@return consistent read view */
252
when this function is first called for a new started transaction. */
256
255
trx_assign_read_view(
257
256
/*=================*/
258
trx_t* trx); /*!< in: active transaction */
259
/***********************************************************//**
257
/* out: consistent read view */
258
trx_t* trx); /* in: active transaction */
259
/***************************************************************
260
260
The transaction must be in the TRX_QUE_LOCK_WAIT state. Puts it to
261
261
the TRX_QUE_RUNNING state and releases query threads which were
262
262
waiting for a lock in the wait_thrs list. */
265
265
trx_end_lock_wait(
266
266
/*==============*/
267
trx_t* trx); /*!< in: transaction */
268
/****************************************************************//**
267
trx_t* trx); /* in: transaction */
268
/********************************************************************
269
269
Sends a signal to a trx object. */
274
trx_t* trx, /*!< in: trx handle */
275
ulint type, /*!< in: signal type */
276
ulint sender, /*!< in: TRX_SIG_SELF or
274
trx_t* trx, /* in: trx handle */
275
ulint type, /* in: signal type */
276
ulint sender, /* in: TRX_SIG_SELF or
277
277
TRX_SIG_OTHER_SESS */
278
que_thr_t* receiver_thr, /*!< in: query thread which wants the
278
que_thr_t* receiver_thr, /* in: query thread which wants the
279
279
reply, or NULL; if type is
280
280
TRX_SIG_END_WAIT, this must be NULL */
281
trx_savept_t* savept, /*!< in: possible rollback savepoint, or
281
trx_savept_t* savept, /* in: possible rollback savepoint, or
283
que_thr_t** next_thr); /*!< in/out: next query thread to run;
283
que_thr_t** next_thr); /* in/out: next query thread to run;
284
284
if the value which is passed in is
285
285
a pointer to a NULL pointer, then the
286
286
calling function can start running
287
287
a new query thread; if the parameter
288
288
is NULL, it is ignored */
289
/****************************************************************//**
289
/********************************************************************
290
290
Send the reply message when a signal in the queue of the trx has
296
trx_sig_t* sig, /*!< in: signal */
297
que_thr_t** next_thr); /*!< in/out: next query thread to run;
296
trx_sig_t* sig, /* in: signal */
297
que_thr_t** next_thr); /* in/out: next query thread to run;
298
298
if the value which is passed in is
299
299
a pointer to a NULL pointer, then the
300
300
calling function can start running
301
301
a new query thread */
302
/****************************************************************//**
302
/********************************************************************
303
303
Removes the signal object from a trx signal queue. */
308
trx_t* trx, /*!< in: trx handle */
309
trx_sig_t* sig); /*!< in, own: signal */
310
/****************************************************************//**
308
trx_t* trx, /* in: trx handle */
309
trx_sig_t* sig); /* in, own: signal */
310
/********************************************************************
311
311
Starts handling of a trx signal. */
314
314
trx_sig_start_handle(
315
315
/*=================*/
316
trx_t* trx, /*!< in: trx handle */
317
que_thr_t** next_thr); /*!< in/out: next query thread to run;
316
trx_t* trx, /* in: trx handle */
317
que_thr_t** next_thr); /* in/out: next query thread to run;
318
318
if the value which is passed in is
319
319
a pointer to a NULL pointer, then the
320
320
calling function can start running
321
321
a new query thread */
322
/****************************************************************//**
322
/********************************************************************
323
323
Ends signal handling. If the session is in the error state, and
324
324
trx->graph_before_signal_handling != NULL, returns control to the error
325
325
handling routine of the graph (currently only returns the control to the
329
329
trx_end_signal_handling(
330
330
/*====================*/
331
trx_t* trx); /*!< in: trx */
332
/*********************************************************************//**
333
Creates a commit command node struct.
334
@return own: commit node struct */
331
trx_t* trx); /* in: trx */
332
/*************************************************************************
333
Creates a commit command node struct. */
337
336
commit_node_create(
338
337
/*===============*/
339
mem_heap_t* heap); /*!< in: mem heap where created */
340
/***********************************************************//**
341
Performs an execution step for a commit type node in a query graph.
342
@return query thread to run next, or NULL */
338
/* out, own: commit node struct */
339
mem_heap_t* heap); /* in: mem heap where created */
340
/***************************************************************
341
Performs an execution step for a commit type node in a query graph. */
347
que_thr_t* thr); /*!< in: query thread */
346
/* out: query thread to run next, or NULL */
347
que_thr_t* thr); /* in: query thread */
349
/**********************************************************************//**
349
/**************************************************************************
350
350
Prints info about a transaction to the given file. The caller must own the
351
kernel mutex and must have called
352
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
353
or InnoDB cannot meanwhile change the info printed here. */
356
FILE* f, /*!< in: output stream */
357
trx_t* trx, /*!< in: transaction */
358
ulint max_query_len); /*!< in: max query length to print, or 0 to
358
FILE* f, /* in: output stream */
359
trx_t* trx, /* in: transaction */
360
ulint max_query_len); /* in: max query length to print, or 0 to
359
361
use the default max length */
361
363
/** Type of data dictionary operation */
362
typedef enum trx_dict_op {
363
365
/** The transaction is not modifying the data dictionary. */
364
366
TRX_DICT_OP_NONE = 0,
365
367
/** The transaction is creating a table or an index, or
371
373
existing table. In crash recovery, the the data dictionary
372
374
must be locked, but the table must not be dropped. */
373
375
TRX_DICT_OP_INDEX = 2
376
/**********************************************************************//**
377
Determine if a transaction is a dictionary operation.
378
@return dictionary operation mode */
378
/**************************************************************************
379
Determine if a transaction is a dictionary operation. */
381
382
trx_get_dict_operation(
382
383
/*===================*/
383
const trx_t* trx) /*!< in: transaction */
384
/* out: dictionary operation mode */
385
const trx_t* trx) /* in: transaction */
384
386
__attribute__((pure));
385
/**********************************************************************//**
387
/**************************************************************************
386
388
Flag a transaction a dictionary operation. */
389
391
trx_set_dict_operation(
390
392
/*===================*/
391
trx_t* trx, /*!< in/out: transaction */
392
enum trx_dict_op op); /*!< in: operation, not
393
trx_t* trx, /* in/out: transaction */
394
enum trx_dict_op op); /* in: operation, not
393
395
TRX_DICT_OP_NONE */
395
397
#ifndef UNIV_HOTBACKUP
396
/**********************************************************************//**
397
Determines if the currently running transaction has been interrupted.
398
@return TRUE if interrupted */
398
/**************************************************************************
399
Determines if the currently running transaction has been interrupted. */
401
402
trx_is_interrupted(
402
403
/*===============*/
403
trx_t* trx); /*!< in: transaction */
404
/**********************************************************************//**
405
Determines if the currently running transaction is in strict mode.
406
@return TRUE if strict */
411
trx_t* trx); /*!< in: transaction */
404
/* out: TRUE if interrupted */
405
trx_t* trx); /* in: transaction */
412
406
#else /* !UNIV_HOTBACKUP */
413
407
#define trx_is_interrupted(trx) FALSE
414
408
#endif /* !UNIV_HOTBACKUP */
416
/*******************************************************************//**
410
/**************************************************************************
411
Determines if the currently running transaction is in innodb_strict_mode. */
416
/* out: TRUE if strict */
417
trx_t* trx); /* in: transaction */
419
/***********************************************************************
417
420
Calculates the "weight" of a transaction. The weight of one transaction
418
421
is estimated as the number of altered rows + the number of locked rows.
420
@return transaction weight */
421
#define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->trx_locks))
423
/*******************************************************************//**
424
#define TRX_WEIGHT(t) \
425
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
427
/***********************************************************************
424
428
Compares the "weight" (or size) of two transactions. Transactions that
425
429
have edited non-transactional tables are considered heavier than ones
427
@return TRUE if weight(a) >= weight(b) */
432
const trx_t* a, /*!< in: the first transaction to be compared */
433
const trx_t* b); /*!< in: the second transaction to be compared */
435
/* out: <0, 0 or >0; similar to strcmp(3) */
436
const trx_t* a, /* in: the first transaction to be compared */
437
const trx_t* b); /* in: the second transaction to be compared */
439
/***********************************************************************
440
Retrieves transacion's id, represented as unsigned long long. */
445
/* out: transaction's id */
446
const trx_t* trx); /* in: transaction */
435
448
/* Maximum length of a string that can be returned by
436
449
trx_get_que_state_str(). */
437
450
#define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */
439
/*******************************************************************//**
452
/***********************************************************************
440
453
Retrieves transaction's que state in a human readable string. The string
441
should not be free()'d or modified.
442
@return string in the data segment */
454
should not be free()'d or modified. */
445
457
trx_get_que_state_str(
446
458
/*==================*/
447
const trx_t* trx); /*!< in: transaction */
459
/* out: string in the data segment */
460
const trx_t* trx); /* in: transaction */
449
462
/* Signal to a transaction */
450
463
struct trx_sig_struct{
451
unsigned type:3; /*!< signal type */
452
unsigned sender:1; /*!< TRX_SIG_SELF or
464
unsigned type:3; /* signal type */
465
unsigned sender:1; /* TRX_SIG_SELF or
453
466
TRX_SIG_OTHER_SESS */
454
que_thr_t* receiver; /*!< non-NULL if the sender of the signal
467
que_thr_t* receiver; /* non-NULL if the sender of the signal
455
468
wants reply after the operation induced
456
469
by the signal is completed */
457
trx_savept_t savept; /*!< possible rollback savepoint */
470
trx_savept_t savept; /* possible rollback savepoint */
458
471
UT_LIST_NODE_T(trx_sig_t)
459
signals; /*!< queue of pending signals to the
472
signals; /* queue of pending signals to the
461
474
UT_LIST_NODE_T(trx_sig_t)
462
reply_signals; /*!< list of signals for which the sender
475
reply_signals; /* list of signals for which the sender
463
476
transaction is waiting a reply */
472
485
struct trx_struct{
475
/* These fields are not protected by any mutex. */
476
const char* op_info; /*!< English text describing the
487
/* All the next fields are protected by the kernel mutex, except the
488
undo logs which are protected by undo_mutex */
489
const char* op_info; /* English text describing the
477
490
current operation, or an empty
479
ulint conc_state; /*!< state of the trx from the point
492
unsigned is_purge:1; /* 0=user transaction, 1=purge */
493
unsigned is_recovered:1; /* 0=normal transaction,
494
1=recovered, must be rolled back */
495
unsigned conc_state:2; /* state of the trx from the point
480
496
of view of concurrency control:
481
497
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
483
ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
484
ulint check_foreigns; /* normally TRUE, but if the user
499
unsigned que_state:2; /* valid when conc_state == TRX_ACTIVE:
500
TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
502
unsigned isolation_level:2;/* TRX_ISO_REPEATABLE_READ, ... */
503
unsigned check_foreigns:1;/* normally TRUE, but if the user
485
504
wants to suppress foreign key checks,
486
505
(in table imports, for example) we
487
506
set this FALSE */
488
unsigned check_unique_secondary;
507
unsigned check_unique_secondary:1;
489
508
/* normally TRUE, but if the user
490
509
wants to speed up inserts by
491
510
suppressing unique key checks
492
511
for secondary indexes when we decide
493
512
if we can use the insert buffer for
494
513
them, we set this FALSE */
495
unsigned support_xa; /*!< normally we do the XA two-phase
514
unsigned support_xa:1; /* normally we do the XA two-phase
496
515
commit steps, but by setting this to
497
516
FALSE, one can save CPU time and about
498
517
150 bytes in the undo log size as then
499
518
we skip XA steps */
500
unsigned flush_log_later;/* In 2PC, we hold the
501
prepare_commit mutex across
502
both phases. In that case, we
503
defer flush of the logs to disk
504
until after we release the
506
unsigned must_flush_log_later;/* this flag is set to TRUE in
519
unsigned flush_log_later:1;/* when we commit the transaction
520
in MySQL's binlog write, we will
521
flush the log to disk later in
523
unsigned must_flush_log_later:1;/* this flag is set to TRUE in
507
524
trx_commit_off_kernel() if
508
525
flush_log_later was TRUE, and there
509
526
were modifications by the transaction;
510
527
in that case we must flush the log
511
528
in trx_commit_complete_for_mysql() */
512
ulint duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
513
unsigned has_search_latch;
529
unsigned dict_operation:2;/**< @see enum trx_dict_op */
530
unsigned duplicates:2; /* TRX_DUP_IGNORE | TRX_DUP_REPLACE */
531
unsigned active_trans:2; /* 1 - if a transaction in MySQL
532
is active. 2 - if prepare_commit_mutex
534
unsigned has_search_latch:1;
514
535
/* TRUE if this trx has latched the
515
536
search system latch in S-mode */
516
ulint deadlock_mark; /*!< a mark field used in deadlock
517
checking algorithm. */
518
trx_dict_op_t dict_operation; /**< @see enum trx_dict_op */
520
/* Fields protected by the srv_conc_mutex. */
521
ulint declared_to_be_inside_innodb;
537
unsigned declared_to_be_inside_innodb:1;
522
538
/* this is TRUE if we have declared
523
539
this transaction in
524
540
srv_conc_enter_innodb to be inside the
527
/* Fields protected by dict_operation_lock. The very latch
528
it is used to track. */
529
ulint dict_operation_lock_mode;
530
/*!< 0, RW_S_LATCH, or RW_X_LATCH:
542
unsigned handling_signals:1;/* this is TRUE as long as the trx
543
is handling signals */
544
unsigned dict_operation_lock_mode:2;
545
/* 0, RW_S_LATCH, or RW_X_LATCH:
531
546
the latch mode trx currently holds
532
547
on dict_operation_lock */
534
/* All the next fields are protected by the kernel mutex, except the
535
undo logs which are protected by undo_mutex */
536
ulint is_purge; /*!< 0=user transaction, 1=purge */
537
ulint is_recovered; /*!< 0=normal transaction,
538
1=recovered, must be rolled back */
539
ulint que_state; /*!< valid when conc_state
540
== TRX_ACTIVE: TRX_QUE_RUNNING,
541
TRX_QUE_LOCK_WAIT, ... */
542
ulint handling_signals;/* this is TRUE as long as the trx
543
is handling signals */
544
time_t start_time; /*!< time the trx object was created
548
time_t start_time; /* time the trx object was created
545
549
or the state last time became
547
trx_id_t id; /*!< transaction id */
548
XID xid; /*!< X/Open XA transaction
551
dulint id; /* transaction id */
552
XID xid; /* X/Open XA transaction
549
553
identification to identify a
550
554
transaction branch */
551
trx_id_t no; /*!< transaction serialization number ==
555
dulint no; /* transaction serialization number ==
552
556
max trx id when the transaction is
553
557
moved to COMMITTED_IN_MEMORY state */
554
ib_uint64_t commit_lsn; /*!< lsn at the time of the commit */
555
table_id_t table_id; /*!< Table to drop iff dict_operation
558
ib_uint64_t commit_lsn; /* lsn at the time of the commit */
559
dulint table_id; /* Table to drop iff dict_operation
560
is TRUE, or ut_dulint_zero. */
557
561
/*------------------------------*/
558
drizzled::Session *mysql_thd; /*!< MySQL thread handle corresponding
562
void* mysql_thd; /* MySQL thread handle corresponding
559
563
to this trx, or NULL */
564
char** mysql_query_str;/* pointer to the field in mysqld_thd
565
which contains the pointer to the
566
current SQL query string */
560
567
const char* mysql_log_file_name;
561
568
/* if MySQL binlog is used, this field
562
569
contains a pointer to the latest file
591
602
to srv_conc_innodb_enter, if the value
592
603
here is > 0, we decrement this by 1 */
593
604
/*------------------------------*/
594
UT_LIST_NODE_T(trx_t)
595
trx_list; /*!< list of transactions */
596
UT_LIST_NODE_T(trx_t)
597
mysql_trx_list; /*!< list of transactions created for
605
dict_index_t* new_rec_locks[2];/* these are normally NULL; if
606
srv_locks_unsafe_for_binlog is TRUE
607
or session is using READ COMMITTED
609
in a cursor search, if we set a new
610
record lock on an index, this is set
611
to point to the index; this is
612
used in releasing the locks under the
613
cursors if we are performing an UPDATE
614
and we determine after retrieving
615
the row that it does not need to be
616
locked; thus, these can be used to
617
implement a 'mini-rollback' that
618
releases the latest record locks */
619
UT_LIST_NODE_T(trx_t)
620
trx_list; /* list of transactions */
621
UT_LIST_NODE_T(trx_t)
622
mysql_trx_list; /* list of transactions created for
599
624
/*------------------------------*/
600
ulint error_state; /*!< 0 if no error, otherwise error
625
ulint error_state; /* 0 if no error, otherwise error
601
626
number; NOTE That ONLY the thread
602
627
doing the transaction is allowed to
603
628
set this field: this is NOT protected
604
629
by the kernel mutex */
605
const dict_index_t*error_info; /*!< if the error number indicates a
630
const dict_index_t*error_info; /* if the error number indicates a
606
631
duplicate key error, a pointer to
607
632
the problematic index is stored here */
608
ulint error_key_num; /*!< if the index creation fails to a
633
ulint error_key_num; /* if the index creation fails to a
609
634
duplicate key error, a mysql key
610
635
number of that index is stored here */
611
sess_t* sess; /*!< session of the trx, NULL if none */
612
que_t* graph; /*!< query currently run in the session,
636
sess_t* sess; /* session of the trx, NULL if none */
637
que_t* graph; /* query currently run in the session,
613
638
or NULL if none; NOTE that the query
614
639
belongs to the session, and it can
615
640
survive over a transaction commit, if
616
641
it is a stored procedure with a COMMIT
617
642
WORK statement, for instance */
618
ulint n_active_thrs; /*!< number of active query threads */
643
ulint n_active_thrs; /* number of active query threads */
619
644
que_t* graph_before_signal_handling;
620
645
/* value of graph when signal handling
621
646
for this trx started: this is used to
622
647
return control to the original query
623
648
graph for error processing */
624
trx_sig_t sig; /*!< one signal object can be allocated
649
trx_sig_t sig; /* one signal object can be allocated
625
650
in this space, avoiding mem_alloc */
626
651
UT_LIST_BASE_NODE_T(trx_sig_t)
627
signals; /*!< queue of processed or pending
652
signals; /* queue of processed or pending
628
653
signals to the trx */
629
654
UT_LIST_BASE_NODE_T(trx_sig_t)
630
reply_signals; /*!< list of signals sent by the query
655
reply_signals; /* list of signals sent by the query
631
656
threads of this trx for which a thread
632
657
is waiting for a reply; if this trx is
633
658
killed, the reply requests in the list
634
659
must be canceled */
635
660
/*------------------------------*/
636
lock_t* wait_lock; /*!< if trx execution state is
661
lock_t* wait_lock; /* if trx execution state is
637
662
TRX_QUE_LOCK_WAIT, this points to
638
663
the lock request, otherwise this is
643
668
if another transaction chooses this
644
669
transaction as a victim in deadlock
645
670
resolution, it sets this to TRUE */
646
time_t wait_started; /*!< lock wait started at this time */
671
time_t wait_started; /* lock wait started at this time */
647
672
UT_LIST_BASE_NODE_T(que_thr_t)
648
wait_thrs; /*!< query threads belonging to this
673
wait_thrs; /* query threads belonging to this
649
674
trx that are in the QUE_THR_LOCK_WAIT
676
ulint deadlock_mark; /* a mark field used in deadlock
677
checking algorithm. This must be
678
in its own machine word, because
679
it can be changed by other
680
threads while holding kernel_mutex. */
651
681
/*------------------------------*/
652
mem_heap_t* lock_heap; /*!< memory heap for the locks of the
682
mem_heap_t* lock_heap; /* memory heap for the locks of the
654
684
UT_LIST_BASE_NODE_T(lock_t)
655
trx_locks; /*!< locks reserved by the transaction */
685
trx_locks; /* locks reserved by the transaction */
656
686
/*------------------------------*/
657
687
mem_heap_t* global_read_view_heap;
658
688
/* memory heap for the global read
689
719
was started: in case of an error, trx
690
720
is rolled back down to this undo
691
721
number; see note at undo_mutex! */
692
trx_rseg_t* rseg; /*!< rollback segment assigned to the
722
trx_rseg_t* rseg; /* rollback segment assigned to the
693
723
transaction, or NULL if not assigned
695
trx_undo_t* insert_undo; /*!< pointer to the insert undo log, or
725
trx_undo_t* insert_undo; /* pointer to the insert undo log, or
696
726
NULL if no inserts performed yet */
697
trx_undo_t* update_undo; /*!< pointer to the update undo log, or
727
trx_undo_t* update_undo; /* pointer to the update undo log, or
698
728
NULL if no update performed yet */
699
undo_no_t roll_limit; /*!< least undo number to undo during
729
dulint roll_limit; /* least undo number to undo during
701
ulint pages_undone; /*!< number of undo log pages undone
731
ulint pages_undone; /* number of undo log pages undone
702
732
since the last undo log truncation */
703
trx_undo_arr_t* undo_no_arr; /*!< array of undo numbers of undo log
733
trx_undo_arr_t* undo_no_arr; /* array of undo numbers of undo log
704
734
records which are currently processed
705
735
by a rollback operation */
706
736
/*------------------------------*/
707
ulint n_autoinc_rows; /*!< no. of AUTO-INC rows required for
737
ulint n_autoinc_rows; /* no. of AUTO-INC rows required for
708
738
an SQL statement. This is useful for
709
739
multi-row INSERTs */
710
740
ib_vector_t* autoinc_locks; /* AUTOINC locks held by this