Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef trx0trx_h
00028 #define trx0trx_h
00029
00030 #include "univ.i"
00031 #include "trx0types.h"
00032 #include "dict0types.h"
00033 #ifndef UNIV_HOTBACKUP
00034 #include "lock0types.h"
00035 #include "usr0types.h"
00036 #include "que0types.h"
00037 #include "mem0mem.h"
00038 #include "read0types.h"
00039 #include "trx0xa.h"
00040 #include "ut0vec.h"
00041
00042 namespace drizzled { class Session; }
00043
00045 extern sess_t* trx_dummy_sess;
00046
00049 extern ulint trx_n_mysql_transactions;
00050
00051
00053 UNIV_INTERN
00054 void
00055 trx_search_latch_release_if_reserved(
00056
00057 trx_t* trx);
00058
00060 UNIV_INTERN
00061 void
00062 trx_set_detailed_error(
00063
00064 trx_t* trx,
00065 const char* msg);
00066
00069 UNIV_INTERN
00070 void
00071 trx_set_detailed_error_from_file(
00072
00073 trx_t* trx,
00074 FILE* file);
00075
00078 UNIV_INLINE
00079 ibool
00080 trx_log_commit_id(
00081
00082 const trx_t* trx);
00083
00086 UNIV_INLINE
00087 const dict_index_t*
00088 trx_get_error_info(
00089
00090 const trx_t* trx);
00091
00094 UNIV_INTERN
00095 trx_t*
00096 trx_create(
00097
00098 sess_t* sess)
00099 __attribute__((nonnull));
00100
00103 UNIV_INTERN
00104 trx_t*
00105 trx_allocate_for_mysql(void);
00106
00107
00110 UNIV_INTERN
00111 trx_t*
00112 trx_allocate_for_background(void);
00113
00114
00116 UNIV_INTERN
00117 void
00118 trx_free(
00119
00120 trx_t* trx);
00121
00123 UNIV_INTERN
00124 void
00125 trx_free_for_mysql(
00126
00127 trx_t* trx);
00128
00130 UNIV_INTERN
00131 void
00132 trx_free_for_background(
00133
00134 trx_t* trx);
00135
00141 UNIV_INTERN
00142 void
00143 trx_lists_init_at_db_start(void);
00144
00145
00149 UNIV_INTERN
00150 ibool
00151 trx_start(
00152
00153 trx_t* trx,
00154 ulint rseg_id);
00157
00160 UNIV_INTERN
00161 ibool
00162 trx_start_low(
00163
00164 trx_t* trx,
00165 ulint rseg_id);
00168
00170 UNIV_INLINE
00171 void
00172 trx_start_if_not_started(
00173
00174 trx_t* trx);
00175
00178 UNIV_INLINE
00179 void
00180 trx_start_if_not_started_low(
00181
00182 trx_t* trx);
00183
00185 UNIV_INTERN
00186 void
00187 trx_commit_off_kernel(
00188
00189 trx_t* trx);
00190
00194 UNIV_INTERN
00195 void
00196 trx_cleanup_at_db_startup(
00197
00198 trx_t* trx);
00199
00202 UNIV_INTERN
00203 ulint
00204 trx_commit_for_mysql(
00205
00206 trx_t* trx);
00207
00210 UNIV_INTERN
00211 ulint
00212 trx_prepare_for_mysql(
00213
00214 trx_t* trx);
00215
00219 UNIV_INTERN
00220 int
00221 trx_recover_for_mysql(
00222
00223 XID* xid_list,
00224 ulint len);
00225
00229 UNIV_INTERN
00230 trx_t *
00231 trx_get_trx_by_xid(
00232
00233 XID* xid);
00234
00238 UNIV_INTERN
00239 ulint
00240 trx_commit_complete_for_mysql(
00241
00242 trx_t* trx);
00243
00245 UNIV_INTERN
00246 void
00247 trx_mark_sql_stat_end(
00248
00249 trx_t* trx);
00250
00255 UNIV_INTERN
00256 read_view_t*
00257 trx_assign_read_view(
00258
00259 trx_t* trx);
00260
00264 UNIV_INTERN
00265 void
00266 trx_end_lock_wait(
00267
00268 trx_t* trx);
00269
00271 UNIV_INTERN
00272 void
00273 trx_sig_send(
00274
00275 trx_t* trx,
00276 ulint type,
00277 ulint sender,
00279 que_thr_t* receiver_thr,
00282 trx_savept_t* savept,
00284 que_thr_t** next_thr);
00290
00293 UNIV_INTERN
00294 void
00295 trx_sig_reply(
00296
00297 trx_sig_t* sig,
00298 que_thr_t** next_thr);
00303
00305 UNIV_INTERN
00306 void
00307 trx_sig_remove(
00308
00309 trx_t* trx,
00310 trx_sig_t* sig);
00311
00313 UNIV_INTERN
00314 void
00315 trx_sig_start_handle(
00316
00317 trx_t* trx,
00318 que_thr_t** next_thr);
00323
00328 UNIV_INTERN
00329 void
00330 trx_end_signal_handling(
00331
00332 trx_t* trx);
00333
00336 UNIV_INTERN
00337 commit_node_t*
00338 commit_node_create(
00339
00340 mem_heap_t* heap);
00341
00344 UNIV_INTERN
00345 que_thr_t*
00346 trx_commit_step(
00347
00348 que_thr_t* thr);
00350
00353 UNIV_INTERN
00354 void
00355 trx_print(
00356
00357 FILE* f,
00358 trx_t* trx,
00359 ulint max_query_len);
00363 typedef enum trx_dict_op {
00365 TRX_DICT_OP_NONE = 0,
00370 TRX_DICT_OP_TABLE = 1,
00374 TRX_DICT_OP_INDEX = 2
00375 } trx_dict_op_t;
00376
00377
00380 UNIV_INLINE
00381 enum trx_dict_op
00382 trx_get_dict_operation(
00383
00384 const trx_t* trx)
00385 __attribute__((pure));
00386
00388 UNIV_INLINE
00389 void
00390 trx_set_dict_operation(
00391
00392 trx_t* trx,
00393 enum trx_dict_op op);
00396 #ifndef UNIV_HOTBACKUP
00397
00400 UNIV_INTERN
00401 ibool
00402 trx_is_interrupted(
00403
00404 trx_t* trx);
00405
00408 UNIV_INTERN
00409 ibool
00410 trx_is_strict(
00411
00412 trx_t* trx);
00413 #else
00414 #define trx_is_interrupted(trx) FALSE
00415 #endif
00416
00417
00422 #define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->trx_locks))
00423
00424
00429 UNIV_INTERN
00430 ibool
00431 trx_weight_ge(
00432
00433 const trx_t* a,
00434 const trx_t* b);
00436
00437
00438 #define TRX_QUE_STATE_STR_MAX_LEN 12
00439
00440
00444 UNIV_INLINE
00445 const char*
00446 trx_get_que_state_str(
00447
00448 const trx_t* trx);
00450
00451 struct trx_sig_struct{
00452 unsigned type:3;
00453 unsigned sender:1;
00455 que_thr_t* receiver;
00458 trx_savept_t savept;
00459 UT_LIST_NODE_T(trx_sig_t)
00460 signals;
00462 UT_LIST_NODE_T(trx_sig_t)
00463 reply_signals;
00465 };
00466
00467 #define TRX_MAGIC_N 91118598
00468
00469
00470
00471
00472
00473 struct trx_struct{
00474 ulint magic_n;
00475
00476
00477 const char* op_info;
00480 ulint conc_state;
00484 ulint isolation_level;
00485 ulint check_foreigns;
00486
00487
00488
00489 unsigned check_unique_secondary;
00490
00491
00492
00493
00494
00495
00496 unsigned support_xa;
00501 unsigned flush_log_later;
00502
00503
00504
00505
00506
00507 unsigned must_flush_log_later;
00508
00509
00510
00511
00512
00513 ulint duplicates;
00514 unsigned has_search_latch;
00515
00516
00517 ulint deadlock_mark;
00519 trx_dict_op_t dict_operation;
00521
00522 ulint declared_to_be_inside_innodb;
00523
00524
00525
00526
00527
00528
00529
00530 ulint dict_operation_lock_mode;
00535
00536
00537 ulint is_purge;
00538 ulint is_recovered;
00540 ulint que_state;
00543 ulint handling_signals;
00544
00545 time_t start_time;
00548 trx_id_t id;
00549 XID xid;
00552 trx_id_t no;
00555 ib_uint64_t commit_lsn;
00556 table_id_t table_id;
00558
00559 drizzled::Session *mysql_thd;
00561 const char* mysql_log_file_name;
00562
00563
00564
00565
00566 ib_int64_t mysql_log_offset;
00567
00568
00569 os_thread_id_t mysql_thread_id;
00570
00571 ulint mysql_process_no;
00572
00573
00574 ulint mysql_n_tables_locked;
00575
00576
00577
00578 ulint search_latch_timeout;
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 ulint n_tickets_to_enter_innodb;
00590
00591
00592
00593
00594
00595 UT_LIST_NODE_T(trx_t)
00596 trx_list;
00597 UT_LIST_NODE_T(trx_t)
00598 mysql_trx_list;
00600
00601 ulint error_state;
00606 const dict_index_t*error_info;
00609 ulint error_key_num;
00612 sess_t* sess;
00613 que_t* graph;
00619 ulint n_active_thrs;
00620 que_t* graph_before_signal_handling;
00621
00622
00623
00624
00625 trx_sig_t sig;
00627 UT_LIST_BASE_NODE_T(trx_sig_t)
00628 signals;
00630 UT_LIST_BASE_NODE_T(trx_sig_t)
00631 reply_signals;
00636
00637 lock_t* wait_lock;
00641 ibool was_chosen_as_deadlock_victim;
00642
00643
00644
00645
00646
00647 time_t wait_started;
00648 UT_LIST_BASE_NODE_T(que_thr_t)
00649 wait_thrs;
00652
00653 mem_heap_t* lock_heap;
00655 UT_LIST_BASE_NODE_T(lock_t)
00656 trx_locks;
00657
00658 mem_heap_t* global_read_view_heap;
00659
00660
00661 read_view_t* global_read_view;
00662
00663
00664 read_view_t* read_view;
00670
00671 UT_LIST_BASE_NODE_T(trx_named_savept_t)
00672 trx_savepoints;
00674
00675 mutex_t undo_mutex;
00681 undo_no_t undo_no;
00688 trx_savept_t last_sql_stat_start;
00689
00690
00691
00692
00693 trx_rseg_t* rseg;
00696 trx_undo_t* insert_undo;
00698 trx_undo_t* update_undo;
00700 undo_no_t roll_limit;
00702 ulint pages_undone;
00704 trx_undo_arr_t* undo_no_arr;
00707
00708 ulint n_autoinc_rows;
00711 ib_vector_t* autoinc_locks;
00712
00713
00714
00715
00716
00717 char detailed_error[256];
00720 ibool log_commit_id;
00722 inline drizzled::Session *session()
00723 {
00724 return mysql_thd;
00725 }
00726 inline drizzled::Session *session() const
00727 {
00728 return mysql_thd;
00729 }
00730 };
00731
00732 #define TRX_MAX_N_THREADS 32
00733
00734
00735
00736
00737
00738 #define TRX_NOT_STARTED 0
00739 #define TRX_ACTIVE 1
00740 #define TRX_COMMITTED_IN_MEMORY 2
00741 #define TRX_PREPARED 3
00742
00743
00744 #define TRX_QUE_RUNNING 0
00745 #define TRX_QUE_LOCK_WAIT 1
00746 #define TRX_QUE_ROLLING_BACK 2
00747 #define TRX_QUE_COMMITTING 3
00748
00749
00750 #define TRX_ISO_READ_UNCOMMITTED 0
00751
00752
00753
00754
00755
00756
00757
00758
00759 #define TRX_ISO_READ_COMMITTED 1
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 #define TRX_ISO_REPEATABLE_READ 2
00773
00774
00775
00776
00777
00778
00779
00780 #define TRX_ISO_SERIALIZABLE 3
00781
00782
00783
00784
00785
00786 #define TRX_DUP_IGNORE 1
00787 #define TRX_DUP_REPLACE 2
00788
00789
00790
00791 #define TRX_SIG_NO_SIGNAL 0
00792 #define TRX_SIG_TOTAL_ROLLBACK 1
00793 #define TRX_SIG_ROLLBACK_TO_SAVEPT 2
00794 #define TRX_SIG_COMMIT 3
00795 #define TRX_SIG_ERROR_OCCURRED 4
00796 #define TRX_SIG_BREAK_EXECUTION 5
00797
00798
00799 #define TRX_SIG_SELF 0
00800
00801
00802 #define TRX_SIG_OTHER_SESS 1
00803
00804
00806 enum commit_node_state {
00807 COMMIT_NODE_SEND = 1,
00809 COMMIT_NODE_WAIT
00811 };
00812
00814 struct commit_node_struct{
00815 que_common_t common;
00816 enum commit_node_state
00817 state;
00818 };
00819
00820
00821
00822 #ifndef UNIV_NONINL
00823 #include "trx0trx.ic"
00824 #endif
00825 #endif
00826
00827 #endif