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 #ifndef _trnman_h
17 #define _trnman_h
18 
19 C_MODE_START
20 
21 #include <lf.h>
22 #include "trnman_public.h"
23 #include "ma_loghandler_lsn.h"
24 
25 /**
26   trid - 6 uchar transaction identifier. Assigned when a transaction
27   is created. Transaction can always be identified by its trid,
28   even after transaction has ended.
29 
30   short_id - 2-byte transaction identifier, identifies a running
31   transaction, is reassigned when transaction ends.
32 
33   when short_id is 0, TRN is not initialized, for all practical purposes
34   it could be considered unused.
35 
36   when commit_trid is MAX_TRID the transaction is running, otherwise it's
37   committed.
38 
39   state_lock mutex protects the state of a TRN, that is whether a TRN
40   is committed/running/unused. Meaning that modifications of short_id and
41   commit_trid happen under this mutex.
42 */
43 
44 struct st_ma_transaction
45 {
46   LF_PINS              *pins;
47   WT_THD               *wt;
48   mysql_mutex_t         state_lock;
49   void                 *used_tables;  /**< Table shares used by transaction */
50   void                 *used_instances; /* table files used by transaction */
51   TRN                  *next, *prev;
52   TrID                 trid, min_read_from, commit_trid;
53   LSN		       rec_lsn, undo_lsn;
54   LSN_WITH_FLAGS       first_undo_lsn;
55   uint                 locked_tables;
56   uint16               short_id;
57   uint16               flags;         /**< Various flags */
58 };
59 
60 #define TRANSACTION_LOGGED_LONG_ID 0x8000000000000000ULL
61 #define MAX_TRID (~(TrID)0)
62 
63 extern WT_RESOURCE_TYPE ma_rc_dup_unique;
64 
65 #ifdef HAVE_PSI_INTERFACE
66 extern PSI_mutex_key key_LOCK_trn_list, key_TRN_state_lock;
67 #endif
68 
69 C_MODE_END
70 
71 #endif
72 
73