466
by Monty Taylor
Fixed modelines... these files are c++. |
1 |
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
3 |
*
|
|
4 |
* Copyright (C) 2008 MySQL
|
|
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; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
21 |
#ifndef DRIZZLED_FIELD_BLOB_H
|
22 |
#define DRIZZLED_FIELD_BLOB_H
|
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
23 |
|
1034.1.3
by Brian Aker
Collapse field classes (this does change enum/time decimal conversion |
24 |
#include <drizzled/field/str.h> |
584.5.1
by Monty Taylor
Removed field includes from field.h. |
25 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
26 |
#include <drizzled/global_charset_info.h> |
1241.9.28
by Monty Taylor
Removed global_charset_info.h from server_includes.h |
27 |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
28 |
#include <string> |
29 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
30 |
#include <drizzled/visibility.h> |
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
31 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
32 |
namespace drizzled |
33 |
{
|
|
34 |
||
1055.2.5
by Jay Pipes
Removal of dead Field::image_type and st_key_part::image_type member variables. Legacy from geometry MyISAM types... |
35 |
/**
|
36 |
* Class representing a BLOB data type column
|
|
37 |
*/
|
|
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
38 |
class DRIZZLED_API Field_blob : |
39 |
public Field_str |
|
40 |
{
|
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
41 |
protected: |
42 |
String value; // For temporaries |
|
43 |
public: |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
44 |
|
45 |
using Field::store; |
|
46 |
using Field::cmp; |
|
47 |
using Field::pack; |
|
48 |
using Field::unpack; |
|
49 |
using Field::val_int; |
|
50 |
using Field::val_str; |
|
51 |
||
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
52 |
Field_blob(unsigned char *ptr_arg, |
53 |
unsigned char *null_ptr_arg, |
|
54 |
unsigned char null_bit_arg, |
|
1119.9.14
by Jay Pipes
Style cleanups after review. Thanks Monty :) |
55 |
const char *field_name_arg, |
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
56 |
TableShare *share, |
57 |
const CHARSET_INFO * const cs); |
|
58 |
Field_blob(uint32_t len_arg, |
|
59 |
bool maybe_null_arg, |
|
60 |
const char *field_name_arg, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
61 |
const CHARSET_INFO * const cs) |
1119.9.14
by Jay Pipes
Style cleanups after review. Thanks Monty :) |
62 |
:Field_str((unsigned char*) NULL, |
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
63 |
len_arg, |
1119.9.14
by Jay Pipes
Style cleanups after review. Thanks Monty :) |
64 |
maybe_null_arg ? (unsigned char *) "": 0, |
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
65 |
0, |
66 |
field_name_arg, |
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
67 |
cs) |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
68 |
{
|
69 |
flags|= BLOB_FLAG; |
|
70 |
}
|
|
1267.1.2
by Stewart Smith
remove Field_blob constructor that only takes packlength as argument. It's never even called |
71 |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
72 |
enum_field_types type() const { return DRIZZLE_TYPE_BLOB;} |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
73 |
enum ha_base_keytype key_type() const |
74 |
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; } |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
75 |
int store(const char *to,uint32_t length, |
76 |
const CHARSET_INFO * const charset); |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
77 |
int store(double nr); |
78 |
int store(int64_t nr, bool unsigned_val); |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
79 |
|
2181.2.1
by Brian Aker
Protect all of the val_* methods from modification. |
80 |
double val_real(void) const; |
81 |
int64_t val_int(void) const; |
|
82 |
String *val_str(String*,String *) const; |
|
83 |
type::Decimal *val_decimal(type::Decimal *) const; |
|
481
by Brian Aker
Remove all of uchar. |
84 |
int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length); |
85 |
int cmp(const unsigned char *a,const unsigned char *b) |
|
365.2.6
by Monty Taylor
Undid some stupid int->int16_t conversions. |
86 |
{ return cmp_max(a, b, UINT32_MAX); } |
481
by Brian Aker
Remove all of uchar. |
87 |
int cmp(const unsigned char *a, uint32_t a_length, const unsigned char *b, uint32_t b_length); |
88 |
int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX); |
|
89 |
int key_cmp(const unsigned char *,const unsigned char*); |
|
482
by Brian Aker
Remove uint. |
90 |
int key_cmp(const unsigned char *str, uint32_t length); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
91 |
uint32_t key_length() const { return 0; } |
482
by Brian Aker
Remove uint. |
92 |
void sort_string(unsigned char *buff,uint32_t length); |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
93 |
uint32_t pack_length() const; |
94 |
||
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
95 |
|
96 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
97 |
Return the packed length without the pointer size added.
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
98 |
|
99 |
This is used to determine the size of the actual data in the row
|
|
100 |
buffer.
|
|
101 |
||
102 |
@returns The length of the raw data itself without the pointer.
|
|
103 |
*/
|
|
104 |
uint32_t pack_length_no_ptr() const |
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
105 |
{ return (uint32_t) (sizeof(uint32_t)); } |
1267.1.5
by Stewart Smith
merge trunk |
106 |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
107 |
uint32_t sort_length() const; |
108 |
virtual uint32_t max_data_length() const |
|
109 |
{
|
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
110 |
return (uint32_t) (((uint64_t) 1 << 32) -1); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
111 |
}
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
112 |
int reset(void) { memset(ptr, 0, sizeof(uint32_t)+sizeof(unsigned char*)); return 0; } |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
113 |
void reset_fields() { memset(&value, 0, sizeof(value)); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
114 |
#ifndef WORDS_BIGENDIAN
|
115 |
static
|
|
116 |
#endif
|
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
117 |
void store_length(unsigned char *i_ptr, uint32_t i_number, bool low_byte_first); |
118 |
void store_length(unsigned char *i_ptr, uint32_t i_number); |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
119 |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
120 |
inline void store_length(uint32_t number) |
121 |
{
|
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
122 |
store_length(ptr, number); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
123 |
}
|
124 |
||
125 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
126 |
Return the packed length plus the length of the data.
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
127 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
128 |
This is used to determine the size of the data plus the
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
129 |
packed length portion in the row data.
|
130 |
||
131 |
@returns The length in the row plus the size of the data.
|
|
132 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
133 |
uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
134 |
|
2181.2.1
by Brian Aker
Protect all of the val_* methods from modification. |
135 |
DRIZZLED_API uint32_t get_length(uint32_t row_offset= 0) const; |
136 |
DRIZZLED_API uint32_t get_length(const unsigned char *ptr, bool low_byte_first) const; |
|
137 |
DRIZZLED_API uint32_t get_length(const unsigned char *ptr_arg) const; |
|
481
by Brian Aker
Remove all of uchar. |
138 |
void put_length(unsigned char *pos, uint32_t length); |
139 |
inline void get_ptr(unsigned char **str) |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
140 |
{
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
141 |
memcpy(str,ptr+sizeof(uint32_t),sizeof(unsigned char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
142 |
}
|
482
by Brian Aker
Remove uint. |
143 |
inline void get_ptr(unsigned char **str, uint32_t row_offset) |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
144 |
{
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
145 |
memcpy(str,ptr+sizeof(uint32_t)+row_offset,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
146 |
}
|
481
by Brian Aker
Remove all of uchar. |
147 |
inline void set_ptr(unsigned char *length, unsigned char *data) |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
148 |
{
|
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
149 |
memcpy(ptr,length,sizeof(uint32_t)); |
150 |
memcpy(ptr+sizeof(uint32_t),&data,sizeof(char*)); |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
151 |
}
|
1122.2.12
by Monty Taylor
Removed the silly my_ptrdiff_t typedef. |
152 |
void set_ptr_offset(ptrdiff_t ptr_diff, uint32_t length, unsigned char *data) |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
153 |
{
|
481
by Brian Aker
Remove all of uchar. |
154 |
unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*); |
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
155 |
store_length(ptr_ofs, length); |
156 |
memcpy(ptr_ofs+sizeof(uint32_t),&data,sizeof(char*)); |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
157 |
}
|
481
by Brian Aker
Remove all of uchar. |
158 |
inline void set_ptr(uint32_t length, unsigned char *data) |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
159 |
{
|
160 |
set_ptr_offset(0, length, data); |
|
161 |
}
|
|
1055.2.5
by Jay Pipes
Removal of dead Field::image_type and st_key_part::image_type member variables. Legacy from geometry MyISAM types... |
162 |
uint32_t get_key_image(unsigned char *buff,uint32_t length); |
163 |
uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length); |
|
482
by Brian Aker
Remove uint. |
164 |
void set_key_image(const unsigned char *buff,uint32_t length); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
165 |
void sql_type(String &str) const; |
166 |
inline bool copy() |
|
167 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
168 |
unsigned char *tmp; |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
169 |
get_ptr(&tmp); |
170 |
if (value.copy((char*) tmp, get_length(), charset())) |
|
171 |
{
|
|
172 |
Field_blob::reset(); |
|
173 |
return 1; |
|
174 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
175 |
tmp=(unsigned char*) value.ptr(); |
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
176 |
memcpy(ptr+sizeof(uint32_t),&tmp,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
177 |
return 0; |
178 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
179 |
virtual unsigned char *pack(unsigned char *to, const unsigned char *from, |
482
by Brian Aker
Remove uint. |
180 |
uint32_t max_length, bool low_byte_first); |
481
by Brian Aker
Remove all of uchar. |
181 |
unsigned char *pack_key(unsigned char *to, const unsigned char *from, |
482
by Brian Aker
Remove uint. |
182 |
uint32_t max_length, bool low_byte_first); |
481
by Brian Aker
Remove all of uchar. |
183 |
virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from, |
1267.1.4
by Stewart Smith
remove last bits of packlength from Field_blob, leaving only support for 4 byte length for blobs (not 1, not 2 and certainly not 3). |
184 |
uint32_t , bool low_byte_first); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
185 |
void free() { value.free(); } |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
186 |
inline void clear_temporary() { memset(&value, 0, sizeof(value)); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
187 |
friend int field_conv(Field *to,Field *from); |
482
by Brian Aker
Remove uint. |
188 |
uint32_t size_of() const { return sizeof(*this); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
189 |
bool has_charset(void) const |
190 |
{ return charset() == &my_charset_bin ? false : true; } |
|
191 |
uint32_t max_display_length(); |
|
192 |
};
|
|
193 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
194 |
} /* namespace drizzled */ |
195 |
||
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
196 |
#endif /* DRIZZLED_FIELD_BLOB_H */ |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
197 |