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 02111-1301 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
29C_MODE_START
30typedef uint64 TrID; /* our TrID is 6 bytes */
31typedef struct st_ma_transaction TRN;
32
33#define SHORT_TRID_MAX 65535
34
35extern uint trnman_active_transactions, trnman_allocated_transactions;
36extern TRN dummy_transaction_object;
37extern my_bool (*trnman_end_trans_hook)(TRN *trn, my_bool commit,
38 my_bool active_transactions);
39
40int trnman_init(TrID);
41void trnman_destroy(void);
42TRN *trnman_new_trn(WT_THD *wt);
43my_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)
47int trnman_can_read_from(TRN *trn, TrID trid);
48TRN *trnman_trid_to_trn(TRN *trn, TrID trid);
49void trnman_new_statement(TRN *trn);
50void trnman_rollback_statement(TRN *trn);
51my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
52 LSN *min_rec_lsn,
53 LSN *min_first_undo_lsn);
54
55uint trnman_increment_locked_tables(TRN *trn);
56uint trnman_decrement_locked_tables(TRN *trn);
57uint trnman_has_locked_tables(TRN *trn);
58void trnman_reset_locked_tables(TRN *trn, uint locked_tables);
59TRN *trnman_recreate_trn_from_recovery(uint16 shortid, TrID longid);
60TRN *trnman_get_any_trn(void);
61TrID trnman_get_min_trid(void);
62TrID trnman_get_max_trid(void);
63TrID trnman_get_min_safe_trid();
64my_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)
69void trnman_lock();
70void trnman_unlock();
71my_bool trman_is_inited();
72#ifdef EXTRA_DEBUG
73uint16 trnman_get_flags(TRN *);
74void 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
84C_MODE_END
85#endif
86