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 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
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 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
2225.2.1
by Olaf van der Spek
x |
21 |
#include <cstring> |
934.2.15
by Jay Pipes
Pulls remainder of XID and xid_cache implementation into xid.cc and xid.h from drizzled/session.cc. |
22 |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
23 |
#include <drizzled/xid.h> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
24 |
#include <drizzled/charset.h> |
1689.2.14
by Brian Aker
LOCK_xid_cache now converted to boost. |
25 |
|
2221.6.1
by Olaf van der Spek
Refactor |
26 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
27 |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
28 |
bool XID::eq(XID *xid) |
29 |
{
|
|
30 |
return eq(xid->gtrid_length, xid->bqual_length, xid->data); |
|
31 |
}
|
|
32 |
||
33 |
bool XID::eq(long g, long b, const char *d) |
|
34 |
{
|
|
35 |
return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); |
|
36 |
}
|
|
37 |
||
38 |
void XID::set(XID *xid) |
|
39 |
{
|
|
40 |
memcpy(this, xid, xid->length()); |
|
41 |
}
|
|
42 |
||
43 |
void XID::set(long f, const char *g, long gl, const char *b, long bl) |
|
44 |
{
|
|
45 |
formatID= f; |
|
46 |
memcpy(data, g, gtrid_length= gl); |
|
47 |
memcpy(data+gl, b, bqual_length= bl); |
|
48 |
}
|
|
49 |
||
50 |
void XID::set(uint64_t xid) |
|
51 |
{
|
|
52 |
formatID= 1; |
|
53 |
set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX); |
|
2221.6.1
by Olaf van der Spek
Refactor |
54 |
memcpy(data + DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)); |
55 |
my_xid tmp= xid; |
|
56 |
memcpy(data + DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp)); |
|
57 |
gtrid_length= DRIZZLE_XID_GTRID_LEN; |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
58 |
}
|
59 |
||
60 |
void XID::set(long g, long b, const char *d) |
|
61 |
{
|
|
62 |
formatID= 1; |
|
63 |
gtrid_length= g; |
|
64 |
bqual_length= b; |
|
65 |
memcpy(data, d, g+b); |
|
66 |
}
|
|
67 |
||
68 |
bool XID::is_null() |
|
69 |
{
|
|
70 |
return formatID == -1; |
|
71 |
}
|
|
72 |
||
73 |
void XID::null() |
|
74 |
{
|
|
75 |
formatID= -1; |
|
76 |
}
|
|
77 |
||
78 |
my_xid XID::quick_get_my_xid() |
|
79 |
{
|
|
80 |
my_xid tmp; |
|
2221.6.1
by Olaf van der Spek
Refactor |
81 |
memcpy(&tmp, data + DRIZZLE_XID_OFFSET, sizeof(tmp)); |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
82 |
return tmp; |
83 |
}
|
|
84 |
||
85 |
my_xid XID::get_my_xid() |
|
86 |
{
|
|
87 |
return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 && |
|
88 |
!memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) && |
|
89 |
!memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ? |
|
90 |
quick_get_my_xid() : 0; |
|
91 |
}
|
|
92 |
||
2221.6.1
by Olaf van der Spek
Refactor |
93 |
uint32_t XID::length() const |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
94 |
{
|
95 |
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+ |
|
96 |
gtrid_length+bqual_length; |
|
97 |
}
|
|
98 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
99 |
} /* namespace drizzled */ |