1 /* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; version 2 of the License.
6 
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11 
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
15 
16 
17 /*
18   External definitions for trnman.h
19   We need to split this into two files as gcc 4.1.2 gives error if it tries
20   to include my_atomic.h in C++ code.
21 */
22 
23 #ifndef _trnman_public_h
24 #define _trnman_public_h
25 
26 #include "ma_loghandler_lsn.h"
27 #include <waiting_threads.h>
28 
29 C_MODE_START
30 typedef uint64 TrID; /* our TrID is 6 bytes */
31 typedef struct st_ma_transaction TRN;
32 
33 #define SHORT_TRID_MAX 65535
34 
35 extern uint trnman_active_transactions, trnman_allocated_transactions;
36 extern TRN dummy_transaction_object;
37 extern my_bool (*trnman_end_trans_hook)(TRN *trn, my_bool commit,
38                                         my_bool active_transactions);
39 
40 int trnman_init(TrID);
41 void trnman_destroy(void);
42 TRN *trnman_new_trn(WT_THD *wt);
43 my_bool trnman_end_trn(TRN *trn, my_bool commit);
44 #define trnman_commit_trn(T) trnman_end_trn(T, TRUE)
45 #define trnman_abort_trn(T)  trnman_end_trn(T, FALSE)
46 #define trnman_rollback_trn(T)  trnman_end_trn(T, FALSE)
47 int trnman_can_read_from(TRN *trn, TrID trid);
48 TRN *trnman_trid_to_trn(TRN *trn, TrID trid);
49 void trnman_new_statement(TRN *trn);
50 void trnman_rollback_statement(TRN *trn);
51 my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
52                                     LSN *min_rec_lsn,
53                                     LSN *min_first_undo_lsn);
54 
55 uint trnman_increment_locked_tables(TRN *trn);
56 uint trnman_decrement_locked_tables(TRN *trn);
57 uint trnman_has_locked_tables(TRN *trn);
58 void trnman_reset_locked_tables(TRN *trn, uint locked_tables);
59 TRN *trnman_recreate_trn_from_recovery(uint16 shortid, TrID longid);
60 TRN *trnman_get_any_trn(void);
61 TrID trnman_get_min_trid(void);
62 TrID trnman_get_max_trid(void);
63 TrID trnman_get_min_safe_trid();
64 my_bool trnman_exists_active_transactions(TrID min_id, TrID max_id,
65                                           my_bool trnman_is_locked);
66 #define TRANSID_SIZE		6
67 #define transid_store(dst, id) int6store(dst,id)
68 #define transid_korr(P) uint6korr(P)
69 void trnman_lock();
70 void trnman_unlock();
71 my_bool trman_is_inited();
72 #ifdef EXTRA_DEBUG
73 uint16 trnman_get_flags(TRN *);
74 void trnman_set_flags(TRN *, uint16 flags);
75 #else
76 #define trnman_get_flags(A) 0
77 #define trnman_set_flags(A, B) do { } while (0)
78 #endif
79 
80 /* Flag bits */
81 #define TRN_STATE_INFO_LOGGED       1  /* Query is logged */
82 #define TRN_STATE_TABLES_CAN_CHANGE 2  /* Things can change during trans. */
83 
84 C_MODE_END
85 #endif
86