~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_XID_H
21
 
#define DRIZZLED_XID_H
 
20
#pragma once
 
21
 
 
22
#include <cstring>
 
23
 
 
24
namespace drizzled {
22
25
 
23
26
extern uint32_t server_id;
24
27
 
30
33
 
31
34
*/
32
35
 
33
 
typedef uint64_t my_xid; // this line is the same as in log_event.h
 
36
typedef uint64_t my_xid;
34
37
 
35
38
#define DRIZZLE_XIDDATASIZE 128
36
 
#define DRIZZLE_XID_PREFIX "MySQLXid"
 
39
#define DRIZZLE_XID_PREFIX "DrizzleXid"
37
40
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
38
41
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
39
42
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
40
43
 
41
 
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
42
 
 
43
 
class XID {
44
 
 
 
44
class XID
 
45
{
45
46
public:
46
 
 
47
47
  long formatID;
48
48
  long gtrid_length;
49
49
  long bqual_length;
50
 
  char data[XIDDATASIZE];  // not \0-terminated !
 
50
  char data[DRIZZLE_XIDDATASIZE];  // not \0-terminated !
51
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);
 
52
  XID() :
 
53
    formatID(-1), /* -1 == null */
 
54
    gtrid_length(0),
 
55
    bqual_length(0)
 
56
  {
 
57
    memset(data, 0, DRIZZLE_XIDDATASIZE);
 
58
  }
57
59
  void set(uint64_t xid);
58
60
  void set(long g, long b, const char *d);
59
 
  bool is_null();
60
 
  void null();
 
61
  bool is_null() const;
 
62
  void set_null();
61
63
  my_xid quick_get_my_xid();
62
64
  my_xid get_my_xid();
63
 
  uint32_t length();
64
 
  unsigned char *key();
65
 
  uint32_t key_length();
 
65
  uint32_t length() const;
66
66
};
67
67
 
68
68
/**
69
 
  struct st_drizzle_xid is binary compatible with the XID structure as
 
69
  struct st_DrizzleXid is binary compatible with the XID structure as
70
70
  in the X/Open CAE Specification, Distributed Transaction Processing:
71
71
  The XA Specification, X/Open Company Ltd., 1991.
72
72
  http://www.opengroup.org/bookstore/catalog/c193.htm
73
73
 
74
74
*/
75
 
struct st_drizzle_xid {
 
75
 
 
76
class DrizzleXid
 
77
{
 
78
public:
76
79
  long formatID;
77
80
  long gtrid_length;
78
81
  long bqual_length;
79
82
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
 
83
 
 
84
  DrizzleXid() :
 
85
    formatID(0),
 
86
    gtrid_length(0),
 
87
    bqual_length(0)
 
88
  {
 
89
    memset(data, 0, DRIZZLE_XIDDATASIZE);
 
90
  }
80
91
};
81
 
typedef struct st_drizzle_xid DRIZZLE_XID;
82
 
 
83
 
 
84
 
/* for recover() handlerton call */
 
92
 
 
93
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
 
94
extern const char *xa_state_names[];
 
95
 
 
96
/* for recover() plugin::StorageEngine call */
85
97
#define MIN_XID_LIST_SIZE  128
86
98
#define MAX_XID_LIST_SIZE  (1024*128)
87
99
 
88
 
#endif /* DRIZZLED_XID_H */
 
100
class XID_STATE
 
101
{
 
102
public:
 
103
  XID_STATE() :
 
104
    xa_state(XA_NOTR),
 
105
    in_session(false)
 
106
  {}
 
107
  /* For now, this is only used to catch duplicated external xids */
 
108
  XID  xid;                           // transaction identifier
 
109
  xa_states xa_state;            // used by external XA only
 
110
  bool in_session;
 
111
};
 
112
 
 
113
} /* namespace drizzled */
 
114