~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

  • Committer: Monty Taylor
  • Date: 2010-02-05 08:11:15 UTC
  • mfrom: (1283 build)
  • mto: (1273.13.43 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: mordred@inaugust.com-20100205081115-dr82nvrwv4lvw7sd
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_XID_H
21
21
#define DRIZZLED_XID_H
22
22
 
 
23
#include <cstring>
 
24
 
 
25
namespace drizzled
 
26
{
 
27
 
23
28
extern uint32_t server_id;
24
29
 
25
30
/**
30
35
 
31
36
*/
32
37
 
33
 
typedef uint64_t my_xid; // this line is the same as in log_event.h
 
38
typedef uint64_t my_xid;
34
39
 
35
40
#define DRIZZLE_XIDDATASIZE 128
36
41
#define DRIZZLE_XID_PREFIX "MySQLXid"
38
43
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
39
44
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
40
45
 
41
 
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
42
 
 
43
46
class XID {
44
47
 
45
48
public:
47
50
  long formatID;
48
51
  long gtrid_length;
49
52
  long bqual_length;
50
 
  char data[XIDDATASIZE];  // not \0-terminated !
 
53
  char data[DRIZZLE_XIDDATASIZE];  // not \0-terminated !
51
54
 
52
 
  XID();
 
55
  XID() :
 
56
    formatID(-1), /* -1 == null */
 
57
    gtrid_length(0),
 
58
    bqual_length(0)
 
59
  {
 
60
    memset(data, 0, DRIZZLE_XIDDATASIZE);
 
61
  }
53
62
  bool eq(XID *xid);
54
63
  bool eq(long g, long b, const char *d);
55
64
  void set(XID *xid);
87
96
#define MIN_XID_LIST_SIZE  128
88
97
#define MAX_XID_LIST_SIZE  (1024*128)
89
98
 
90
 
typedef struct st_xid_state {
 
99
class XID_STATE 
 
100
{
 
101
public:
 
102
  XID_STATE() :
 
103
    xid(),
 
104
    xa_state(XA_NOTR),
 
105
    in_session(false)
 
106
  {}
91
107
  /* For now, this is only used to catch duplicated external xids */
92
108
  XID  xid;                           // transaction identifier
93
109
  enum xa_states xa_state;            // used by external XA only
94
110
  bool in_session;
95
 
} XID_STATE;
 
111
};
96
112
 
97
113
bool xid_cache_init(void);
98
114
void xid_cache_free(void);
101
117
bool xid_cache_insert(XID_STATE *xid_state);
102
118
void xid_cache_delete(XID_STATE *xid_state);
103
119
 
 
120
} /* namespace drizzled */
 
121
 
104
122
#endif /* DRIZZLED_XID_H */