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#ifndef _trnman_h
17#define _trnman_h
18
19C_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
44struct st_ma_transaction
45{
46 LF_PINS *pins;
47 WT_THD *wt;
48 mysql_mutex_t state_lock;
49 void *used_tables; /**< Tables used by transaction */
50 TRN *next, *prev;
51 TrID trid, min_read_from, commit_trid;
52 LSN rec_lsn, undo_lsn;
53 LSN_WITH_FLAGS first_undo_lsn;
54 uint locked_tables;
55 uint16 short_id;
56 uint16 flags; /**< Various flags */
57};
58
59#define TRANSACTION_LOGGED_LONG_ID 0x8000000000000000ULL
60#define MAX_TRID (~(TrID)0)
61
62extern WT_RESOURCE_TYPE ma_rc_dup_unique;
63
64#ifdef HAVE_PSI_INTERFACE
65extern PSI_mutex_key key_LOCK_trn_list, key_TRN_state_lock;
66#endif
67
68C_MODE_END
69
70#endif
71
72