00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <cstring>
00023
00024 namespace drizzled {
00025
00026 extern uint32_t server_id;
00027
00036 typedef uint64_t my_xid;
00037
00038 #define DRIZZLE_XIDDATASIZE 128
00039 #define DRIZZLE_XID_PREFIX "DrizzleXid"
00040 #define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
00041 #define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
00042 #define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
00043
00044 class XID
00045 {
00046 public:
00047 long formatID;
00048 long gtrid_length;
00049 long bqual_length;
00050 char data[DRIZZLE_XIDDATASIZE];
00051
00052 XID() :
00053 formatID(-1),
00054 gtrid_length(0),
00055 bqual_length(0)
00056 {
00057 memset(data, 0, DRIZZLE_XIDDATASIZE);
00058 }
00059 bool eq(XID *xid);
00060 bool eq(long g, long b, const char *d);
00061 void set(XID *xid);
00062 void set(long f, const char *g, long gl, const char *b, long bl);
00063 void set(uint64_t xid);
00064 void set(long g, long b, const char *d);
00065 bool is_null();
00066 void null();
00067 my_xid quick_get_my_xid();
00068 my_xid get_my_xid();
00069 uint32_t length() const;
00070 const unsigned char* key() const;
00071 uint32_t key_length() const;
00072 };
00073
00082 class DrizzleXid
00083 {
00084 public:
00085 long formatID;
00086 long gtrid_length;
00087 long bqual_length;
00088 char data[DRIZZLE_XIDDATASIZE];
00089
00090 DrizzleXid() :
00091 formatID(0),
00092 gtrid_length(0),
00093 bqual_length(0)
00094 {
00095 memset(data, 0, DRIZZLE_XIDDATASIZE);
00096 }
00097 };
00098
00099 enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
00100 extern const char *xa_state_names[];
00101
00102
00103 #define MIN_XID_LIST_SIZE 128
00104 #define MAX_XID_LIST_SIZE (1024*128)
00105
00106 class XID_STATE
00107 {
00108 public:
00109 XID_STATE() :
00110 xa_state(XA_NOTR),
00111 in_session(false)
00112 {}
00113
00114 XID xid;
00115 xa_states xa_state;
00116 bool in_session;
00117 };
00118
00119 }
00120