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 void set(uint64_t xid);
00060 void set(long g, long b, const char *d);
00061 bool is_null() const;
00062 void set_null();
00063 my_xid quick_get_my_xid();
00064 my_xid get_my_xid();
00065 uint32_t length() const;
00066 };
00067
00076 class DrizzleXid
00077 {
00078 public:
00079 long formatID;
00080 long gtrid_length;
00081 long bqual_length;
00082 char data[DRIZZLE_XIDDATASIZE];
00083
00084 DrizzleXid() :
00085 formatID(0),
00086 gtrid_length(0),
00087 bqual_length(0)
00088 {
00089 memset(data, 0, DRIZZLE_XIDDATASIZE);
00090 }
00091 };
00092
00093 enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
00094 extern const char *xa_state_names[];
00095
00096
00097 #define MIN_XID_LIST_SIZE 128
00098 #define MAX_XID_LIST_SIZE (1024*128)
00099
00100 class XID_STATE
00101 {
00102 public:
00103 XID_STATE() :
00104 xa_state(XA_NOTR),
00105 in_session(false)
00106 {}
00107
00108 XID xid;
00109 xa_states xa_state;
00110 bool in_session;
00111 };
00112
00113 }
00114