1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_XID_H
21
#define DRIZZLED_XID_H
28
extern uint32_t server_id;
31
class XID _may_ be binary compatible with the XID structure as
32
in the X/Open CAE Specification, Distributed Transaction Processing:
33
The XA Specification, X/Open Company Ltd., 1991.
34
http://www.opengroup.org/bookstore/catalog/c193.htm
38
typedef uint64_t my_xid;
40
#define DRIZZLE_XIDDATASIZE 128
41
#define DRIZZLE_XID_PREFIX "MySQLXid"
42
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
43
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
44
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
53
char data[DRIZZLE_XIDDATASIZE]; // not \0-terminated !
56
formatID(-1), /* -1 == null */
60
memset(data, 0, DRIZZLE_XIDDATASIZE);
63
bool eq(long g, long b, const char *d);
65
void set(long f, const char *g, long gl, const char *b, long bl);
66
void set(uint64_t xid);
67
void set(long g, long b, const char *d);
70
my_xid quick_get_my_xid();
74
uint32_t key_length();
78
struct st_drizzle_xid is binary compatible with the XID structure as
79
in the X/Open CAE Specification, Distributed Transaction Processing:
80
The XA Specification, X/Open Company Ltd., 1991.
81
http://www.opengroup.org/bookstore/catalog/c193.htm
84
struct st_drizzle_xid {
88
char data[DRIZZLE_XIDDATASIZE]; /* Not \0-terminated */
90
typedef struct st_drizzle_xid DRIZZLE_XID;
92
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
93
extern const char *xa_state_names[];
95
/* for recover() plugin::StorageEngine call */
96
#define MIN_XID_LIST_SIZE 128
97
#define MAX_XID_LIST_SIZE (1024*128)
107
/* For now, this is only used to catch duplicated external xids */
108
XID xid; // transaction identifier
109
enum xa_states xa_state; // used by external XA only
113
bool xid_cache_init(void);
114
void xid_cache_free(void);
115
XID_STATE *xid_cache_search(XID *xid);
116
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
117
bool xid_cache_insert(XID_STATE *xid_state);
118
void xid_cache_delete(XID_STATE *xid_state);
120
} /* namespace drizzled */
122
#endif /* DRIZZLED_XID_H */