~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_XID_H
21
 
#define DRIZZLED_XID_H
 
20
#pragma once
22
21
 
23
22
#include <cstring>
24
23
 
25
 
namespace drizzled
26
 
{
 
24
namespace drizzled {
27
25
 
28
26
extern uint32_t server_id;
29
27
 
38
36
typedef uint64_t my_xid;
39
37
 
40
38
#define DRIZZLE_XIDDATASIZE 128
41
 
#define DRIZZLE_XID_PREFIX "MySQLXid"
 
39
#define DRIZZLE_XID_PREFIX "DrizzleXid"
42
40
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
43
41
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
44
42
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
45
43
 
46
 
class XID {
47
 
 
 
44
class XID
 
45
{
48
46
public:
49
 
 
50
47
  long formatID;
51
48
  long gtrid_length;
52
49
  long bqual_length;
59
56
  {
60
57
    memset(data, 0, DRIZZLE_XIDDATASIZE);
61
58
  }
62
 
  bool eq(XID *xid);
63
 
  bool eq(long g, long b, const char *d);
64
 
  void set(XID *xid);
65
 
  void set(long f, const char *g, long gl, const char *b, long bl);
66
59
  void set(uint64_t xid);
67
60
  void set(long g, long b, const char *d);
68
61
  bool is_null();
69
 
  void null();
 
62
  void set_null();
70
63
  my_xid quick_get_my_xid();
71
64
  my_xid get_my_xid();
72
 
  uint32_t length();
73
 
  unsigned char *key();
74
 
  uint32_t key_length();
 
65
  uint32_t length() const;
75
66
};
76
67
 
77
68
/**
78
 
  struct st_drizzle_xid is binary compatible with the XID structure as
 
69
  struct st_DrizzleXid is binary compatible with the XID structure as
79
70
  in the X/Open CAE Specification, Distributed Transaction Processing:
80
71
  The XA Specification, X/Open Company Ltd., 1991.
81
72
  http://www.opengroup.org/bookstore/catalog/c193.htm
82
73
 
83
74
*/
84
75
 
85
 
class drizzle_xid {
 
76
class DrizzleXid
 
77
{
86
78
public:
87
79
  long formatID;
88
80
  long gtrid_length;
89
81
  long bqual_length;
90
82
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
91
83
 
92
 
  drizzle_xid() :
 
84
  DrizzleXid() :
93
85
    formatID(0),
94
86
    gtrid_length(0),
95
87
    bqual_length(0)
97
89
    memset(data, 0, DRIZZLE_XIDDATASIZE);
98
90
  }
99
91
};
100
 
typedef class drizzle_xid DRIZZLE_XID;
101
92
 
102
93
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
103
94
extern const char *xa_state_names[];
106
97
#define MIN_XID_LIST_SIZE  128
107
98
#define MAX_XID_LIST_SIZE  (1024*128)
108
99
 
109
 
class XID_STATE 
 
100
class XID_STATE
110
101
{
111
102
public:
112
103
  XID_STATE() :
113
 
    xid(),
114
104
    xa_state(XA_NOTR),
115
105
    in_session(false)
116
106
  {}
117
107
  /* For now, this is only used to catch duplicated external xids */
118
108
  XID  xid;                           // transaction identifier
119
 
  enum xa_states xa_state;            // used by external XA only
 
109
  xa_states xa_state;            // used by external XA only
120
110
  bool in_session;
121
111
};
122
112
 
123
 
bool xid_cache_init(void);
124
 
void xid_cache_free(void);
125
 
XID_STATE *xid_cache_search(XID *xid);
126
 
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
127
 
bool xid_cache_insert(XID_STATE *xid_state);
128
 
void xid_cache_delete(XID_STATE *xid_state);
129
 
 
130
113
} /* namespace drizzled */
131
114
 
132
 
#endif /* DRIZZLED_XID_H */