~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

Reverted 1103

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
36
#define DRIZZLE_XID_PREFIX "MySQLXid"
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);
81
72
  http://www.opengroup.org/bookstore/catalog/c193.htm
82
73
 
83
74
*/
84
 
 
85
 
class drizzle_xid {
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
 
  drizzle_xid() :
93
 
    formatID(0),
94
 
    gtrid_length(0),
95
 
    bqual_length(0)
96
 
  {
97
 
    memset(data, 0, DRIZZLE_XIDDATASIZE);
98
 
  }
99
80
};
100
 
typedef class drizzle_xid DRIZZLE_XID;
 
81
typedef struct st_drizzle_xid DRIZZLE_XID;
101
82
 
102
83
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
103
84
extern const char *xa_state_names[];
104
85
 
105
 
/* for recover() plugin::StorageEngine call */
 
86
/* for recover() StorageEngine call */
106
87
#define MIN_XID_LIST_SIZE  128
107
88
#define MAX_XID_LIST_SIZE  (1024*128)
108
89
 
109
 
class XID_STATE 
110
 
{
111
 
public:
112
 
  XID_STATE() :
113
 
    xid(),
114
 
    xa_state(XA_NOTR),
115
 
    in_session(false)
116
 
  {}
 
90
typedef struct st_xid_state {
117
91
  /* For now, this is only used to catch duplicated external xids */
118
92
  XID  xid;                           // transaction identifier
119
93
  enum xa_states xa_state;            // used by external XA only
120
94
  bool in_session;
121
 
};
 
95
} XID_STATE;
122
96
 
123
97
bool xid_cache_init(void);
124
98
void xid_cache_free(void);
127
101
bool xid_cache_insert(XID_STATE *xid_state);
128
102
void xid_cache_delete(XID_STATE *xid_state);
129
103
 
130
 
} /* namespace drizzled */
131
 
 
132
104
#endif /* DRIZZLED_XID_H */