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> |
25 |
#include <drizzled/global_charset_info.h> |
|
26 |
#include <drizzled/charset_info.h> |
|
1689.2.14
by Brian Aker
LOCK_xid_cache now converted to boost. |
27 |
|
2221.6.1
by Olaf van der Spek
Refactor |
28 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
29 |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
30 |
bool XID::eq(XID *xid) |
31 |
{
|
|
32 |
return eq(xid->gtrid_length, xid->bqual_length, xid->data); |
|
33 |
}
|
|
34 |
||
35 |
bool XID::eq(long g, long b, const char *d) |
|
36 |
{
|
|
37 |
return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); |
|
38 |
}
|
|
39 |
||
40 |
void XID::set(XID *xid) |
|
41 |
{
|
|
42 |
memcpy(this, xid, xid->length()); |
|
43 |
}
|
|
44 |
||
45 |
void XID::set(long f, const char *g, long gl, const char *b, long bl) |
|
46 |
{
|
|
47 |
formatID= f; |
|
48 |
memcpy(data, g, gtrid_length= gl); |
|
49 |
memcpy(data+gl, b, bqual_length= bl); |
|
50 |
}
|
|
51 |
||
52 |
void XID::set(uint64_t xid) |
|
53 |
{
|
|
54 |
formatID= 1; |
|
55 |
set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX); |
|
2221.6.1
by Olaf van der Spek
Refactor |
56 |
memcpy(data + DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)); |
57 |
my_xid tmp= xid; |
|
58 |
memcpy(data + DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp)); |
|
59 |
gtrid_length= DRIZZLE_XID_GTRID_LEN; |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
60 |
}
|
61 |
||
62 |
void XID::set(long g, long b, const char *d) |
|
63 |
{
|
|
64 |
formatID= 1; |
|
65 |
gtrid_length= g; |
|
66 |
bqual_length= b; |
|
67 |
memcpy(data, d, g+b); |
|
68 |
}
|
|
69 |
||
70 |
bool XID::is_null() |
|
71 |
{
|
|
72 |
return formatID == -1; |
|
73 |
}
|
|
74 |
||
75 |
void XID::null() |
|
76 |
{
|
|
77 |
formatID= -1; |
|
78 |
}
|
|
79 |
||
80 |
my_xid XID::quick_get_my_xid() |
|
81 |
{
|
|
82 |
my_xid tmp; |
|
2221.6.1
by Olaf van der Spek
Refactor |
83 |
memcpy(&tmp, data + DRIZZLE_XID_OFFSET, sizeof(tmp)); |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
84 |
return tmp; |
85 |
}
|
|
86 |
||
87 |
my_xid XID::get_my_xid() |
|
88 |
{
|
|
89 |
return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 && |
|
90 |
!memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) && |
|
91 |
!memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ? |
|
92 |
quick_get_my_xid() : 0; |
|
93 |
}
|
|
94 |
||
2221.6.1
by Olaf van der Spek
Refactor |
95 |
uint32_t XID::length() const |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
96 |
{
|
97 |
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+ |
|
98 |
gtrid_length+bqual_length; |
|
99 |
}
|
|
100 |
||
2221.6.1
by Olaf van der Spek
Refactor |
101 |
const unsigned char *XID::key() const |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
102 |
{
|
103 |
return (unsigned char *)>rid_length; |
|
104 |
}
|
|
105 |
||
2221.6.1
by Olaf van der Spek
Refactor |
106 |
uint32_t XID::key_length() const |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
107 |
{
|
108 |
return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length; |
|
109 |
}
|
|
934.2.15
by Jay Pipes
Pulls remainder of XID and xid_cache implementation into xid.cc and xid.h from drizzled/session.cc. |
110 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
111 |
} /* namespace drizzled */ |