~drizzle-trunk/drizzle/development

520.4.31 by Monty Taylor
Removed server_id from common_includes.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#ifndef DRIZZLED_XID_H
21
#define DRIZZLED_XID_H
22
23
extern uint32_t server_id;
24
25
/**
26
  class XID _may_ be binary compatible with the XID structure as
27
  in the X/Open CAE Specification, Distributed Transaction Processing:
28
  The XA Specification, X/Open Company Ltd., 1991.
29
  http://www.opengroup.org/bookstore/catalog/c193.htm
30
31
*/
32
33
typedef uint64_t my_xid; // this line is the same as in log_event.h
34
35
#define DRIZZLE_XIDDATASIZE 128
36
#define DRIZZLE_XID_PREFIX "MySQLXid"
37
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
38
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
39
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
40
41
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
42
43
class XID {
44
45
public:
46
47
  long formatID;
48
  long gtrid_length;
49
  long bqual_length;
50
  char data[XIDDATASIZE];  // not \0-terminated !
51
52
  XID();
53
  bool eq(XID *xid);
54
  bool eq(long g, long b, const char *d);
55
  void set(XID *xid);
56
  void set(long f, const char *g, long gl, const char *b, long bl);
57
  void set(uint64_t xid);
58
  void set(long g, long b, const char *d);
59
  bool is_null();
60
  void null();
61
  my_xid quick_get_my_xid();
62
  my_xid get_my_xid();
63
  uint32_t length();
64
  unsigned char *key();
65
  uint32_t key_length();
66
};
67
68
/**
69
  struct st_drizzle_xid is binary compatible with the XID structure as
70
  in the X/Open CAE Specification, Distributed Transaction Processing:
71
  The XA Specification, X/Open Company Ltd., 1991.
72
  http://www.opengroup.org/bookstore/catalog/c193.htm
73
74
*/
75
struct st_drizzle_xid {
76
  long formatID;
77
  long gtrid_length;
78
  long bqual_length;
79
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
80
};
81
typedef struct st_drizzle_xid DRIZZLE_XID;
82
934.2.15 by Jay Pipes
Pulls remainder of XID and xid_cache implementation into xid.cc and xid.h from drizzled/session.cc.
83
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
84
extern const char *xa_state_names[];
520.4.31 by Monty Taylor
Removed server_id from common_includes.
85
960.2.24 by Monty Taylor
Changed handlerton to StorageEngine.
86
/* for recover() StorageEngine call */
520.4.31 by Monty Taylor
Removed server_id from common_includes.
87
#define MIN_XID_LIST_SIZE  128
88
#define MAX_XID_LIST_SIZE  (1024*128)
89
934.2.15 by Jay Pipes
Pulls remainder of XID and xid_cache implementation into xid.cc and xid.h from drizzled/session.cc.
90
typedef struct st_xid_state {
91
  /* For now, this is only used to catch duplicated external xids */
92
  XID  xid;                           // transaction identifier
93
  enum xa_states xa_state;            // used by external XA only
94
  bool in_session;
95
} XID_STATE;
96
97
bool xid_cache_init(void);
98
void xid_cache_free(void);
99
XID_STATE *xid_cache_search(XID *xid);
100
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
101
bool xid_cache_insert(XID_STATE *xid_state);
102
void xid_cache_delete(XID_STATE *xid_state);
103
520.4.31 by Monty Taylor
Removed server_id from common_includes.
104
#endif /* DRIZZLED_XID_H */