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