~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
20
20
#ifndef DRIZZLED_XID_H
21
21
#define DRIZZLED_XID_H
22
22
 
23
 
#include <cstring>
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
23
extern uint32_t server_id;
29
24
 
30
25
/**
35
30
 
36
31
*/
37
32
 
38
 
typedef uint64_t my_xid;
 
33
typedef uint64_t my_xid; // this line is the same as in log_event.h
39
34
 
40
35
#define DRIZZLE_XIDDATASIZE 128
41
 
#define DRIZZLE_XID_PREFIX "DrizzleXid"
 
36
#define DRIZZLE_XID_PREFIX "MySQLXid"
42
37
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
43
38
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
44
39
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
45
40
 
 
41
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
 
42
 
46
43
class XID {
47
44
 
48
45
public:
50
47
  long formatID;
51
48
  long gtrid_length;
52
49
  long bqual_length;
53
 
  char data[DRIZZLE_XIDDATASIZE];  // not \0-terminated !
 
50
  char data[XIDDATASIZE];  // not \0-terminated !
54
51
 
55
 
  XID() :
56
 
    formatID(-1), /* -1 == null */
57
 
    gtrid_length(0),
58
 
    bqual_length(0)
59
 
  {
60
 
    memset(data, 0, DRIZZLE_XIDDATASIZE);
61
 
  }
 
52
  XID();
62
53
  bool eq(XID *xid);
63
54
  bool eq(long g, long b, const char *d);
64
55
  void set(XID *xid);
75
66
};
76
67
 
77
68
/**
78
 
  struct st_DrizzleXid is binary compatible with the XID structure as
 
69
  struct st_drizzle_xid 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
 
 
85
 
class DrizzleXid {
86
 
public:
 
75
struct st_drizzle_xid {
87
76
  long formatID;
88
77
  long gtrid_length;
89
78
  long bqual_length;
90
79
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
91
 
 
92
 
  DrizzleXid() :
93
 
    formatID(0),
94
 
    gtrid_length(0),
95
 
    bqual_length(0)
96
 
  {
97
 
    memset(data, 0, DRIZZLE_XIDDATASIZE);
98
 
  }
99
80
};
 
81
typedef struct st_drizzle_xid DRIZZLE_XID;
100
82
 
101
83
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
102
84
extern const char *xa_state_names[];
105
87
#define MIN_XID_LIST_SIZE  128
106
88
#define MAX_XID_LIST_SIZE  (1024*128)
107
89
 
108
 
class XID_STATE 
109
 
{
110
 
public:
111
 
  XID_STATE() :
112
 
    xid(),
113
 
    xa_state(XA_NOTR),
114
 
    in_session(false)
115
 
  {}
 
90
typedef struct st_xid_state {
116
91
  /* For now, this is only used to catch duplicated external xids */
117
92
  XID  xid;                           // transaction identifier
118
93
  enum xa_states xa_state;            // used by external XA only
119
94
  bool in_session;
120
 
};
 
95
} XID_STATE;
121
96
 
122
97
bool xid_cache_init(void);
123
98
void xid_cache_free(void);
126
101
bool xid_cache_insert(XID_STATE *xid_state);
127
102
void xid_cache_delete(XID_STATE *xid_state);
128
103
 
129
 
} /* namespace drizzled */
130
 
 
131
104
#endif /* DRIZZLED_XID_H */