drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
xid.h
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, Inc.
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#pragma once
21
22#include <cstring>
23
24namespace drizzled {
25
26extern uint32_t server_id;
27
35
36typedef uint64_t my_xid;
37
38#define DRIZZLE_XIDDATASIZE 128
39#define DRIZZLE_XID_PREFIX "DrizzleXid"
40#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
41#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
42#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
43
44class XID
45{
46public:
47 long formatID;
48 long gtrid_length;
49 long bqual_length;
50 char data[DRIZZLE_XIDDATASIZE]; // not \0-terminated !
51
52 XID() :
53 formatID(-1), /* -1 == null */
54 gtrid_length(0),
55 bqual_length(0)
56 {
57 memset(data, 0, DRIZZLE_XIDDATASIZE);
58 }
59 void set(uint64_t xid);
60 void set(long g, long b, const char *d);
61 bool is_null() const;
62 void set_null();
63 my_xid quick_get_my_xid();
64 my_xid get_my_xid();
65 uint32_t length() const;
66};
67
75
76class DrizzleXid
77{
78public:
79 long formatID;
80 long gtrid_length;
81 long bqual_length;
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 }
91};
92
93enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
94extern const char *xa_state_names[];
95
96/* for recover() plugin::StorageEngine call */
97#define MIN_XID_LIST_SIZE 128
98#define MAX_XID_LIST_SIZE (1024*128)
99
100class XID_STATE
101{
102public:
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
TODO: Rename this file - func.h is stupid.
uint64_t my_xid
Definition common_fwd.h:349