00001 /****************************************************** 00002 The transaction 00003 00004 (c) 1996 Innobase Oy 00005 00006 Created 3/26/1996 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef trx0trx_h 00010 #define trx0trx_h 00011 00012 #include "univ.i" 00013 #include "trx0types.h" 00014 #include "lock0types.h" 00015 #include "usr0types.h" 00016 #include "que0types.h" 00017 #include "mem0mem.h" 00018 #include "read0types.h" 00019 #include "dict0types.h" 00020 #include "trx0xa.h" 00021 00022 extern ulint trx_n_mysql_transactions; 00023 00024 /***************************************************************** 00025 Resets the new record lock info in a transaction struct. */ 00026 UNIV_INLINE 00027 void 00028 trx_reset_new_rec_lock_info( 00029 /*========================*/ 00030 trx_t* trx); /* in: transaction struct */ 00031 /***************************************************************** 00032 Registers that we have set a new record lock on an index. We only have space 00033 to store 2 indexes! If this is called to store more than 2 indexes after 00034 trx_reset_new_rec_lock_info(), then this function does nothing. */ 00035 UNIV_INLINE 00036 void 00037 trx_register_new_rec_lock( 00038 /*======================*/ 00039 trx_t* trx, /* in: transaction struct */ 00040 dict_index_t* index); /* in: trx sets a new record lock on this 00041 index */ 00042 /***************************************************************** 00043 Checks if trx has set a new record lock on an index. */ 00044 UNIV_INLINE 00045 ibool 00046 trx_new_rec_locks_contain( 00047 /*======================*/ 00048 /* out: TRUE if trx has set a new record lock 00049 on index */ 00050 trx_t* trx, /* in: transaction struct */ 00051 dict_index_t* index); /* in: index */ 00052 /************************************************************************ 00053 Releases the search latch if trx has reserved it. */ 00054 00055 void 00056 trx_search_latch_release_if_reserved( 00057 /*=================================*/ 00058 trx_t* trx); /* in: transaction */ 00059 /********************************************************************** 00060 Set detailed error message for the transaction. */ 00061 void 00062 trx_set_detailed_error( 00063 /*===================*/ 00064 trx_t* trx, /* in: transaction struct */ 00065 const char* msg); /* in: detailed error message */ 00066 /***************************************************************** 00067 Set detailed error message for the transaction from a file. Note that the 00068 file is rewinded before reading from it. */ 00069 00070 void 00071 trx_set_detailed_error_from_file( 00072 /*=============================*/ 00073 trx_t* trx, /* in: transaction struct */ 00074 FILE* file); /* in: file to read message from */ 00075 /******************************************************************** 00076 Retrieves the error_info field from a trx. */ 00077 00078 void* 00079 trx_get_error_info( 00080 /*===============*/ 00081 /* out: the error info */ 00082 trx_t* trx); /* in: trx object */ 00083 /******************************************************************** 00084 Creates and initializes a transaction object. */ 00085 00086 trx_t* 00087 trx_create( 00088 /*=======*/ 00089 /* out, own: the transaction */ 00090 sess_t* sess); /* in: session or NULL */ 00091 /************************************************************************ 00092 Creates a transaction object for MySQL. */ 00093 00094 trx_t* 00095 trx_allocate_for_mysql(void); 00096 /*========================*/ 00097 /* out, own: transaction object */ 00098 /************************************************************************ 00099 Creates a transaction object for background operations by the master thread. */ 00100 00101 trx_t* 00102 trx_allocate_for_background(void); 00103 /*=============================*/ 00104 /* out, own: transaction object */ 00105 /************************************************************************ 00106 Frees a transaction object. */ 00107 00108 void 00109 trx_free( 00110 /*=====*/ 00111 trx_t* trx); /* in, own: trx object */ 00112 /************************************************************************ 00113 Frees a transaction object for MySQL. */ 00114 00115 void 00116 trx_free_for_mysql( 00117 /*===============*/ 00118 trx_t* trx); /* in, own: trx object */ 00119 /************************************************************************ 00120 Frees a transaction object of a background operation of the master thread. */ 00121 00122 void 00123 trx_free_for_background( 00124 /*====================*/ 00125 trx_t* trx); /* in, own: trx object */ 00126 /******************************************************************** 00127 Creates trx objects for transactions and initializes the trx list of 00128 trx_sys at database start. Rollback segment and undo log lists must 00129 already exist when this function is called, because the lists of 00130 transactions to be rolled back or cleaned up are built based on the 00131 undo log lists. */ 00132 00133 void 00134 trx_lists_init_at_db_start(void); 00135 /*============================*/ 00136 /******************************************************************** 00137 Starts a new transaction. */ 00138 00139 ibool 00140 trx_start( 00141 /*======*/ 00142 /* out: TRUE if success, FALSE if the rollback 00143 segment could not support this many transactions */ 00144 trx_t* trx, /* in: transaction */ 00145 ulint rseg_id);/* in: rollback segment id; if ULINT_UNDEFINED 00146 is passed, the system chooses the rollback segment 00147 automatically in a round-robin fashion */ 00148 /******************************************************************** 00149 Starts a new transaction. */ 00150 00151 ibool 00152 trx_start_low( 00153 /*==========*/ 00154 /* out: TRUE */ 00155 trx_t* trx, /* in: transaction */ 00156 ulint rseg_id);/* in: rollback segment id; if ULINT_UNDEFINED 00157 is passed, the system chooses the rollback segment 00158 automatically in a round-robin fashion */ 00159 /***************************************************************** 00160 Starts the transaction if it is not yet started. */ 00161 UNIV_INLINE 00162 void 00163 trx_start_if_not_started( 00164 /*=====================*/ 00165 trx_t* trx); /* in: transaction */ 00166 /***************************************************************** 00167 Starts the transaction if it is not yet started. Assumes we have reserved 00168 the kernel mutex! */ 00169 UNIV_INLINE 00170 void 00171 trx_start_if_not_started_low( 00172 /*=========================*/ 00173 trx_t* trx); /* in: transaction */ 00174 /***************************************************************** 00175 Starts the transaction if it is not yet started. */ 00176 00177 void 00178 trx_start_if_not_started_noninline( 00179 /*===============================*/ 00180 trx_t* trx); /* in: transaction */ 00181 /******************************************************************** 00182 Commits a transaction. */ 00183 00184 void 00185 trx_commit_off_kernel( 00186 /*==================*/ 00187 trx_t* trx); /* in: transaction */ 00188 /******************************************************************** 00189 Cleans up a transaction at database startup. The cleanup is needed if 00190 the transaction already got to the middle of a commit when the database 00191 crashed, andf we cannot roll it back. */ 00192 00193 void 00194 trx_cleanup_at_db_startup( 00195 /*======================*/ 00196 trx_t* trx); /* in: transaction */ 00197 /************************************************************************** 00198 Does the transaction commit for MySQL. */ 00199 00200 ulint 00201 trx_commit_for_mysql( 00202 /*=================*/ 00203 /* out: 0 or error number */ 00204 trx_t* trx); /* in: trx handle */ 00205 /************************************************************************** 00206 Does the transaction prepare for MySQL. */ 00207 00208 ulint 00209 trx_prepare_for_mysql( 00210 /*==================*/ 00211 /* out: 0 or error number */ 00212 trx_t* trx); /* in: trx handle */ 00213 /************************************************************************** 00214 This function is used to find number of prepared transactions and 00215 their transaction objects for a recovery. */ 00216 00217 int 00218 trx_recover_for_mysql( 00219 /*==================*/ 00220 /* out: number of prepared transactions */ 00221 XID* xid_list, /* in/out: prepared transactions */ 00222 ulint len); /* in: number of slots in xid_list */ 00223 /*********************************************************************** 00224 This function is used to find one X/Open XA distributed transaction 00225 which is in the prepared state */ 00226 trx_t * 00227 trx_get_trx_by_xid( 00228 /*===============*/ 00229 /* out: trx or NULL */ 00230 XID* xid); /* in: X/Open XA transaction identification */ 00231 /************************************************************************** 00232 If required, flushes the log to disk if we called trx_commit_for_mysql() 00233 with trx->flush_log_later == TRUE. */ 00234 00235 ulint 00236 trx_commit_complete_for_mysql( 00237 /*==========================*/ 00238 /* out: 0 or error number */ 00239 trx_t* trx); /* in: trx handle */ 00240 /************************************************************************** 00241 Marks the latest SQL statement ended. */ 00242 00243 void 00244 trx_mark_sql_stat_end( 00245 /*==================*/ 00246 trx_t* trx); /* in: trx handle */ 00247 /************************************************************************ 00248 Assigns a read view for a consistent read query. All the consistent reads 00249 within the same transaction will get the same read view, which is created 00250 when this function is first called for a new started transaction. */ 00251 00252 read_view_t* 00253 trx_assign_read_view( 00254 /*=================*/ 00255 /* out: consistent read view */ 00256 trx_t* trx); /* in: active transaction */ 00257 /*************************************************************** 00258 The transaction must be in the TRX_QUE_LOCK_WAIT state. Puts it to 00259 the TRX_QUE_RUNNING state and releases query threads which were 00260 waiting for a lock in the wait_thrs list. */ 00261 00262 void 00263 trx_end_lock_wait( 00264 /*==============*/ 00265 trx_t* trx); /* in: transaction */ 00266 /******************************************************************** 00267 Sends a signal to a trx object. */ 00268 00269 void 00270 trx_sig_send( 00271 /*=========*/ 00272 trx_t* trx, /* in: trx handle */ 00273 ulint type, /* in: signal type */ 00274 ulint sender, /* in: TRX_SIG_SELF or 00275 TRX_SIG_OTHER_SESS */ 00276 que_thr_t* receiver_thr, /* in: query thread which wants the 00277 reply, or NULL; if type is 00278 TRX_SIG_END_WAIT, this must be NULL */ 00279 trx_savept_t* savept, /* in: possible rollback savepoint, or 00280 NULL */ 00281 que_thr_t** next_thr); /* in/out: next query thread to run; 00282 if the value which is passed in is 00283 a pointer to a NULL pointer, then the 00284 calling function can start running 00285 a new query thread; if the parameter 00286 is NULL, it is ignored */ 00287 /******************************************************************** 00288 Send the reply message when a signal in the queue of the trx has 00289 been handled. */ 00290 00291 void 00292 trx_sig_reply( 00293 /*==========*/ 00294 trx_sig_t* sig, /* in: signal */ 00295 que_thr_t** next_thr); /* in/out: next query thread to run; 00296 if the value which is passed in is 00297 a pointer to a NULL pointer, then the 00298 calling function can start running 00299 a new query thread */ 00300 /******************************************************************** 00301 Removes the signal object from a trx signal queue. */ 00302 00303 void 00304 trx_sig_remove( 00305 /*===========*/ 00306 trx_t* trx, /* in: trx handle */ 00307 trx_sig_t* sig); /* in, own: signal */ 00308 /******************************************************************** 00309 Starts handling of a trx signal. */ 00310 00311 void 00312 trx_sig_start_handle( 00313 /*=================*/ 00314 trx_t* trx, /* in: trx handle */ 00315 que_thr_t** next_thr); /* in/out: next query thread to run; 00316 if the value which is passed in is 00317 a pointer to a NULL pointer, then the 00318 calling function can start running 00319 a new query thread */ 00320 /******************************************************************** 00321 Ends signal handling. If the session is in the error state, and 00322 trx->graph_before_signal_handling != NULL, returns control to the error 00323 handling routine of the graph (currently only returns the control to the 00324 graph root which then sends an error message to the client). */ 00325 00326 void 00327 trx_end_signal_handling( 00328 /*====================*/ 00329 trx_t* trx); /* in: trx */ 00330 /************************************************************************* 00331 Creates a commit command node struct. */ 00332 00333 commit_node_t* 00334 commit_node_create( 00335 /*===============*/ 00336 /* out, own: commit node struct */ 00337 mem_heap_t* heap); /* in: mem heap where created */ 00338 /*************************************************************** 00339 Performs an execution step for a commit type node in a query graph. */ 00340 00341 que_thr_t* 00342 trx_commit_step( 00343 /*============*/ 00344 /* out: query thread to run next, or NULL */ 00345 que_thr_t* thr); /* in: query thread */ 00346 00347 /************************************************************************** 00348 Prints info about a transaction to the given file. The caller must own the 00349 kernel mutex and must have called 00350 innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL 00351 or InnoDB cannot meanwhile change the info printed here. */ 00352 00353 void 00354 trx_print( 00355 /*======*/ 00356 FILE* f, /* in: output stream */ 00357 trx_t* trx, /* in: transaction */ 00358 ulint max_query_len); /* in: max query length to print, or 0 to 00359 use the default max length */ 00360 00361 #ifndef UNIV_HOTBACKUP 00362 /************************************************************************** 00363 Determines if the currently running transaction has been interrupted. */ 00364 00365 ibool 00366 trx_is_interrupted( 00367 /*===============*/ 00368 /* out: TRUE if interrupted */ 00369 trx_t* trx); /* in: transaction */ 00370 #else /* !UNIV_HOTBACKUP */ 00371 #define trx_is_interrupted(trx) FALSE 00372 #endif /* !UNIV_HOTBACKUP */ 00373 00374 00375 /* Signal to a transaction */ 00376 struct trx_sig_struct{ 00377 ulint type; /* signal type */ 00378 ulint state; /* TRX_SIG_WAITING or 00379 TRX_SIG_BEING_HANDLED */ 00380 ulint sender; /* TRX_SIG_SELF or 00381 TRX_SIG_OTHER_SESS */ 00382 que_thr_t* receiver; /* non-NULL if the sender of the signal 00383 wants reply after the operation induced 00384 by the signal is completed */ 00385 trx_savept_t savept; /* possible rollback savepoint */ 00386 UT_LIST_NODE_T(trx_sig_t) 00387 signals; /* queue of pending signals to the 00388 transaction */ 00389 UT_LIST_NODE_T(trx_sig_t) 00390 reply_signals; /* list of signals for which the sender 00391 transaction is waiting a reply */ 00392 }; 00393 00394 #define TRX_MAGIC_N 91118598 00395 00396 /* The transaction handle; every session has a trx object which is freed only 00397 when the session is freed; in addition there may be session-less transactions 00398 rolling back after a database recovery */ 00399 00400 struct trx_struct{ 00401 ulint magic_n; 00402 /* All the next fields are protected by the kernel mutex, except the 00403 undo logs which are protected by undo_mutex */ 00404 const char* op_info; /* English text describing the 00405 current operation, or an empty 00406 string */ 00407 ulint type; /* TRX_USER, TRX_PURGE */ 00408 ulint conc_state; /* state of the trx from the point 00409 of view of concurrency control: 00410 TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY, 00411 ... */ 00412 time_t start_time; /* time the trx object was created 00413 or the state last time became 00414 TRX_ACTIVE */ 00415 ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */ 00416 ibool check_foreigns; /* normally TRUE, but if the user 00417 wants to suppress foreign key checks, 00418 (in table imports, for example) we 00419 set this FALSE */ 00420 ibool check_unique_secondary; 00421 /* normally TRUE, but if the user 00422 wants to speed up inserts by 00423 suppressing unique key checks 00424 for secondary indexes when we decide 00425 if we can use the insert buffer for 00426 them, we set this FALSE */ 00427 dulint id; /* transaction id */ 00428 XID xid; /* X/Open XA transaction 00429 identification to identify a 00430 transaction branch */ 00431 ibool support_xa; /* normally we do the XA two-phase 00432 commit steps, but by setting this to 00433 FALSE, one can save CPU time and about 00434 150 bytes in the undo log size as then 00435 we skip XA steps */ 00436 dulint no; /* transaction serialization number == 00437 max trx id when the transaction is 00438 moved to COMMITTED_IN_MEMORY state */ 00439 ibool flush_log_later;/* when we commit the transaction 00440 in MySQL's binlog write, we will 00441 flush the log to disk later in 00442 a separate call */ 00443 ibool must_flush_log_later;/* this flag is set to TRUE in 00444 trx_commit_off_kernel() if 00445 flush_log_later was TRUE, and there 00446 were modifications by the transaction; 00447 in that case we must flush the log 00448 in trx_commit_complete_for_mysql() */ 00449 dulint commit_lsn; /* lsn at the time of the commit */ 00450 ibool dict_operation; /* TRUE if the trx is used to create 00451 a table, create an index, or drop a 00452 table. This is a hint that the table 00453 may need to be dropped in crash 00454 recovery. */ 00455 dulint table_id; /* table id if the preceding field is 00456 TRUE */ 00457 /*------------------------------*/ 00458 int active_trans; /* 1 - if a transaction in MySQL 00459 is active. 2 - if prepare_commit_mutex 00460 was taken */ 00461 void* mysql_thd; /* MySQL thread handle corresponding 00462 to this trx, or NULL */ 00463 char** mysql_query_str;/* pointer to the field in mysqld_thd 00464 which contains the pointer to the 00465 current SQL query string */ 00466 const char* mysql_log_file_name; 00467 /* if MySQL binlog is used, this field 00468 contains a pointer to the latest file 00469 name; this is NULL if binlog is not 00470 used */ 00471 ib_longlong mysql_log_offset;/* if MySQL binlog is used, this field 00472 contains the end offset of the binlog 00473 entry */ 00474 const char* mysql_master_log_file_name; 00475 /* if the database server is a MySQL 00476 replication slave, we have here the 00477 master binlog name up to which 00478 replication has processed; otherwise 00479 this is a pointer to a null 00480 character */ 00481 ib_longlong mysql_master_log_pos; 00482 /* if the database server is a MySQL 00483 replication slave, this is the 00484 position in the log file up to which 00485 replication has processed */ 00486 /* A MySQL variable mysql_thd->synchronous_repl tells if we have 00487 to use synchronous replication. See ha_innodb.cc. */ 00488 char* repl_wait_binlog_name;/* NULL, or if synchronous MySQL 00489 replication is used, the binlog name 00490 up to which we must communicate the 00491 binlog to the slave, before returning 00492 from a commit; this is the same as 00493 mysql_log_file_name, but we allocate 00494 and copy the name to a separate buffer 00495 here */ 00496 ib_longlong repl_wait_binlog_pos;/* see above at 00497 repl_wait_binlog_name */ 00498 00499 os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated 00500 with this transaction object */ 00501 ulint mysql_process_no;/* since in Linux, 'top' reports 00502 process id's and not thread id's, we 00503 store the process number too */ 00504 /*------------------------------*/ 00505 ulint n_mysql_tables_in_use; /* number of Innobase tables 00506 used in the processing of the current 00507 SQL statement in MySQL */ 00508 ulint mysql_n_tables_locked; 00509 /* how many tables the current SQL 00510 statement uses, except those 00511 in consistent read */ 00512 ibool dict_operation_lock_mode; 00513 /* 0, RW_S_LATCH, or RW_X_LATCH: 00514 the latch mode trx currently holds 00515 on dict_operation_lock */ 00516 ibool has_search_latch; 00517 /* TRUE if this trx has latched the 00518 search system latch in S-mode */ 00519 ulint search_latch_timeout; 00520 /* If we notice that someone is 00521 waiting for our S-lock on the search 00522 latch to be released, we wait in 00523 row0sel.c for BTR_SEA_TIMEOUT new 00524 searches until we try to keep 00525 the search latch again over 00526 calls from MySQL; this is intended 00527 to reduce contention on the search 00528 latch */ 00529 /*------------------------------*/ 00530 ibool declared_to_be_inside_innodb; 00531 /* this is TRUE if we have declared 00532 this transaction in 00533 srv_conc_enter_innodb to be inside the 00534 InnoDB engine */ 00535 ulint n_tickets_to_enter_innodb; 00536 /* this can be > 0 only when 00537 declared_to_... is TRUE; when we come 00538 to srv_conc_innodb_enter, if the value 00539 here is > 0, we decrement this by 1 */ 00540 /*------------------------------*/ 00541 lock_t* auto_inc_lock; /* possible auto-inc lock reserved by 00542 the transaction; note that it is also 00543 in the lock list trx_locks */ 00544 dict_index_t* new_rec_locks[2];/* these are normally NULL; if 00545 srv_locks_unsafe_for_binlog is TRUE 00546 or session is using READ COMMITTED 00547 isolation level, 00548 in a cursor search, if we set a new 00549 record lock on an index, this is set 00550 to point to the index; this is 00551 used in releasing the locks under the 00552 cursors if we are performing an UPDATE 00553 and we determine after retrieving 00554 the row that it does not need to be 00555 locked; thus, these can be used to 00556 implement a 'mini-rollback' that 00557 releases the latest record locks */ 00558 UT_LIST_NODE_T(trx_t) 00559 trx_list; /* list of transactions */ 00560 UT_LIST_NODE_T(trx_t) 00561 mysql_trx_list; /* list of transactions created for 00562 MySQL */ 00563 /*------------------------------*/ 00564 ulint error_state; /* 0 if no error, otherwise error 00565 number; NOTE That ONLY the thread 00566 doing the transaction is allowed to 00567 set this field: this is NOT protected 00568 by the kernel mutex */ 00569 void* error_info; /* if the error number indicates a 00570 duplicate key error, a pointer to 00571 the problematic index is stored here */ 00572 sess_t* sess; /* session of the trx, NULL if none */ 00573 ulint que_state; /* TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT, 00574 ... */ 00575 que_t* graph; /* query currently run in the session, 00576 or NULL if none; NOTE that the query 00577 belongs to the session, and it can 00578 survive over a transaction commit, if 00579 it is a stored procedure with a COMMIT 00580 WORK statement, for instance */ 00581 ulint n_active_thrs; /* number of active query threads */ 00582 ibool handling_signals;/* this is TRUE as long as the trx 00583 is handling signals */ 00584 que_t* graph_before_signal_handling; 00585 /* value of graph when signal handling 00586 for this trx started: this is used to 00587 return control to the original query 00588 graph for error processing */ 00589 trx_sig_t sig; /* one signal object can be allocated 00590 in this space, avoiding mem_alloc */ 00591 UT_LIST_BASE_NODE_T(trx_sig_t) 00592 signals; /* queue of processed or pending 00593 signals to the trx */ 00594 UT_LIST_BASE_NODE_T(trx_sig_t) 00595 reply_signals; /* list of signals sent by the query 00596 threads of this trx for which a thread 00597 is waiting for a reply; if this trx is 00598 killed, the reply requests in the list 00599 must be canceled */ 00600 /*------------------------------*/ 00601 lock_t* wait_lock; /* if trx execution state is 00602 TRX_QUE_LOCK_WAIT, this points to 00603 the lock request, otherwise this is 00604 NULL */ 00605 ibool was_chosen_as_deadlock_victim; 00606 /* when the transaction decides to wait 00607 for a lock, this it sets this to FALSE; 00608 if another transaction chooses this 00609 transaction as a victim in deadlock 00610 resolution, it sets this to TRUE */ 00611 time_t wait_started; /* lock wait started at this time */ 00612 UT_LIST_BASE_NODE_T(que_thr_t) 00613 wait_thrs; /* query threads belonging to this 00614 trx that are in the QUE_THR_LOCK_WAIT 00615 state */ 00616 ulint deadlock_mark; /* a mark field used in deadlock 00617 checking algorithm */ 00618 /*------------------------------*/ 00619 mem_heap_t* lock_heap; /* memory heap for the locks of the 00620 transaction */ 00621 UT_LIST_BASE_NODE_T(lock_t) 00622 trx_locks; /* locks reserved by the transaction */ 00623 /*------------------------------*/ 00624 mem_heap_t* global_read_view_heap; 00625 /* memory heap for the global read 00626 view */ 00627 read_view_t* global_read_view; 00628 /* consistent read view associated 00629 to a transaction or NULL */ 00630 read_view_t* read_view; /* consistent read view used in the 00631 transaction or NULL, this read view 00632 if defined can be normal read view 00633 associated to a transaction (i.e. 00634 same as global_read_view) or read view 00635 associated to a cursor */ 00636 /*------------------------------*/ 00637 UT_LIST_BASE_NODE_T(trx_named_savept_t) 00638 trx_savepoints; /* savepoints set with SAVEPOINT ..., 00639 oldest first */ 00640 /*------------------------------*/ 00641 mutex_t undo_mutex; /* mutex protecting the fields in this 00642 section (down to undo_no_arr), EXCEPT 00643 last_sql_stat_start, which can be 00644 accessed only when we know that there 00645 cannot be any activity in the undo 00646 logs! */ 00647 dulint undo_no; /* next undo log record number to 00648 assign */ 00649 trx_savept_t last_sql_stat_start; 00650 /* undo_no when the last sql statement 00651 was started: in case of an error, trx 00652 is rolled back down to this undo 00653 number; see note at undo_mutex! */ 00654 trx_rseg_t* rseg; /* rollback segment assigned to the 00655 transaction, or NULL if not assigned 00656 yet */ 00657 trx_undo_t* insert_undo; /* pointer to the insert undo log, or 00658 NULL if no inserts performed yet */ 00659 trx_undo_t* update_undo; /* pointer to the update undo log, or 00660 NULL if no update performed yet */ 00661 dulint roll_limit; /* least undo number to undo during 00662 a rollback */ 00663 ulint pages_undone; /* number of undo log pages undone 00664 since the last undo log truncation */ 00665 trx_undo_arr_t* undo_no_arr; /* array of undo numbers of undo log 00666 records which are currently processed 00667 by a rollback operation */ 00668 /*------------------------------*/ 00669 char detailed_error[256]; /* detailed error message for last 00670 error, or empty. */ 00671 }; 00672 00673 #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent 00674 threads running a single operation of 00675 a transaction, e.g., a parallel query */ 00676 /* Transaction types */ 00677 #define TRX_USER 1 /* normal user transaction */ 00678 #define TRX_PURGE 2 /* purge transaction: this is not 00679 inserted to the trx list of trx_sys 00680 and no rollback segment is assigned to 00681 this */ 00682 /* Transaction concurrency states */ 00683 #define TRX_NOT_STARTED 1 00684 #define TRX_ACTIVE 2 00685 #define TRX_COMMITTED_IN_MEMORY 3 00686 #define TRX_PREPARED 4 /* Support for 2PC/XA */ 00687 00688 /* Transaction execution states when trx state is TRX_ACTIVE */ 00689 #define TRX_QUE_RUNNING 1 /* transaction is running */ 00690 #define TRX_QUE_LOCK_WAIT 2 /* transaction is waiting for a lock */ 00691 #define TRX_QUE_ROLLING_BACK 3 /* transaction is rolling back */ 00692 #define TRX_QUE_COMMITTING 4 /* transaction is committing */ 00693 00694 /* Transaction isolation levels */ 00695 #define TRX_ISO_READ_UNCOMMITTED 1 /* dirty read: non-locking 00696 SELECTs are performed so that 00697 we do not look at a possible 00698 earlier version of a record; 00699 thus they are not 'consistent' 00700 reads under this isolation 00701 level; otherwise like level 00702 2 */ 00703 00704 #define TRX_ISO_READ_COMMITTED 2 /* somewhat Oracle-like 00705 isolation, except that in 00706 range UPDATE and DELETE we 00707 must block phantom rows 00708 with next-key locks; 00709 SELECT ... FOR UPDATE and ... 00710 LOCK IN SHARE MODE only lock 00711 the index records, NOT the 00712 gaps before them, and thus 00713 allow free inserting; 00714 each consistent read reads its 00715 own snapshot */ 00716 00717 #define TRX_ISO_REPEATABLE_READ 3 /* this is the default; 00718 all consistent reads in the 00719 same trx read the same 00720 snapshot; 00721 full next-key locking used 00722 in locking reads to block 00723 insertions into gaps */ 00724 00725 #define TRX_ISO_SERIALIZABLE 4 /* all plain SELECTs are 00726 converted to LOCK IN SHARE 00727 MODE reads */ 00728 00729 /* Types of a trx signal */ 00730 #define TRX_SIG_NO_SIGNAL 100 00731 #define TRX_SIG_TOTAL_ROLLBACK 1 00732 #define TRX_SIG_ROLLBACK_TO_SAVEPT 2 00733 #define TRX_SIG_COMMIT 3 00734 #define TRX_SIG_ERROR_OCCURRED 4 00735 #define TRX_SIG_BREAK_EXECUTION 5 00736 00737 /* Sender types of a signal */ 00738 #define TRX_SIG_SELF 1 /* sent by the session itself, or 00739 by an error occurring within this 00740 session */ 00741 #define TRX_SIG_OTHER_SESS 2 /* sent by another session (which 00742 must hold rights to this) */ 00743 /* Signal states */ 00744 #define TRX_SIG_WAITING 1 00745 #define TRX_SIG_BEING_HANDLED 2 00746 00747 /* Commit command node in a query graph */ 00748 struct commit_node_struct{ 00749 que_common_t common; /* node type: QUE_NODE_COMMIT */ 00750 ulint state; /* node execution state */ 00751 }; 00752 00753 /* Commit node states */ 00754 #define COMMIT_NODE_SEND 1 00755 #define COMMIT_NODE_WAIT 2 00756 00757 00758 #ifndef UNIV_NONINL 00759 #include "trx0trx.ic" 00760 #endif 00761 00762 #endif
1.4.7

