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 |
||
21 |
#ifndef DRIZZLE_SERVER_FIELD_BLOB
|
|
22 |
#define DRIZZLE_SERVER_FIELD_BLOB
|
|
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 |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
26 |
#include <string> |
27 |
||
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... |
28 |
/**
|
29 |
* Class representing a BLOB data type column
|
|
30 |
*/
|
|
1034.1.3
by Brian Aker
Collapse field classes (this does change enum/time decimal conversion |
31 |
class Field_blob :public Field_str { |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
32 |
protected: |
482
by Brian Aker
Remove uint. |
33 |
uint32_t packlength; |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
34 |
String value; // For temporaries |
35 |
public: |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
36 |
|
37 |
using Field::store; |
|
38 |
using Field::cmp; |
|
39 |
using Field::pack; |
|
40 |
using Field::unpack; |
|
41 |
using Field::val_int; |
|
42 |
using Field::val_str; |
|
43 |
||
44 |
||
481
by Brian Aker
Remove all of uchar. |
45 |
Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg, |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
46 |
enum utype unireg_check_arg, const char *field_name_arg, |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
47 |
TableShare *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs); |
617
by Brian Aker
ulong fixes |
48 |
Field_blob(uint32_t len_arg, bool maybe_null_arg, 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. |
49 |
const CHARSET_INFO * const cs) |
1034.1.3
by Brian Aker
Collapse field classes (this does change enum/time decimal conversion |
50 |
:Field_str((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0, |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
51 |
NONE, field_name_arg, cs), |
52 |
packlength(4) |
|
53 |
{
|
|
54 |
flags|= BLOB_FLAG; |
|
55 |
}
|
|
617
by Brian Aker
ulong fixes |
56 |
Field_blob(uint32_t len_arg, bool maybe_null_arg, 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. |
57 |
const CHARSET_INFO * const cs, bool set_packlength) |
1034.1.3
by Brian Aker
Collapse field classes (this does change enum/time decimal conversion |
58 |
:Field_str((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0, |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
59 |
NONE, field_name_arg, cs) |
60 |
{
|
|
61 |
flags|= BLOB_FLAG; |
|
62 |
packlength= 4; |
|
63 |
if (set_packlength) |
|
64 |
{
|
|
65 |
uint32_t l_char_length= len_arg/cs->mbmaxlen; |
|
66 |
packlength= l_char_length <= 255 ? 1 : |
|
67 |
l_char_length <= 65535 ? 2 : |
|
68 |
l_char_length <= 16777215 ? 3 : 4; |
|
69 |
}
|
|
70 |
}
|
|
71 |
Field_blob(uint32_t packlength_arg) |
|
1034.1.3
by Brian Aker
Collapse field classes (this does change enum/time decimal conversion |
72 |
:Field_str((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info), |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
73 |
packlength(packlength_arg) {} |
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
74 |
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 |
75 |
enum ha_base_keytype key_type() const |
76 |
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; } |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
77 |
int store(const char *to,uint32_t length, |
78 |
const CHARSET_INFO * const charset); |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
79 |
int store(double nr); |
80 |
int store(int64_t nr, bool unsigned_val); |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
81 |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
82 |
double val_real(void); |
83 |
int64_t val_int(void); |
|
84 |
String *val_str(String*,String *); |
|
85 |
my_decimal *val_decimal(my_decimal *); |
|
481
by Brian Aker
Remove all of uchar. |
86 |
int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length); |
87 |
int cmp(const unsigned char *a,const unsigned char *b) |
|
365.2.6
by Monty Taylor
Undid some stupid int->int16_t conversions. |
88 |
{ return cmp_max(a, b, UINT32_MAX); } |
481
by Brian Aker
Remove all of uchar. |
89 |
int cmp(const unsigned char *a, uint32_t a_length, const unsigned char *b, uint32_t b_length); |
90 |
int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX); |
|
91 |
int key_cmp(const unsigned char *,const unsigned char*); |
|
482
by Brian Aker
Remove uint. |
92 |
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 |
93 |
uint32_t key_length() const { return 0; } |
482
by Brian Aker
Remove uint. |
94 |
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. |
95 |
uint32_t pack_length() const; |
96 |
||
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
97 |
|
98 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
99 |
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 |
100 |
|
101 |
This is used to determine the size of the actual data in the row
|
|
102 |
buffer.
|
|
103 |
||
104 |
@returns The length of the raw data itself without the pointer.
|
|
105 |
*/
|
|
106 |
uint32_t pack_length_no_ptr() const |
|
107 |
{ return (uint32_t) (packlength); } |
|
482
by Brian Aker
Remove uint. |
108 |
uint32_t row_pack_length() { return pack_length_no_ptr(); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
109 |
uint32_t sort_length() const; |
110 |
virtual uint32_t max_data_length() const |
|
111 |
{
|
|
112 |
return (uint32_t) (((uint64_t) 1 << (packlength*8)) -1); |
|
113 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
114 |
int reset(void) { memset(ptr, 0, packlength+sizeof(unsigned char*)); return 0; } |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
115 |
void reset_fields() { memset(&value, 0, sizeof(value)); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
116 |
#ifndef WORDS_BIGENDIAN
|
117 |
static
|
|
118 |
#endif
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
119 |
void store_length(unsigned char *i_ptr, uint32_t i_packlength, |
120 |
uint32_t i_number, bool low_byte_first); |
|
121 |
void store_length(unsigned char *i_ptr, uint32_t i_packlength, |
|
122 |
uint32_t i_number); |
|
123 |
||
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
124 |
inline void store_length(uint32_t number) |
125 |
{
|
|
126 |
store_length(ptr, packlength, number); |
|
127 |
}
|
|
128 |
||
129 |
/**
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
130 |
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 |
131 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
132 |
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 |
133 |
packed length portion in the row data.
|
134 |
||
135 |
@returns The length in the row plus the size of the data.
|
|
136 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
137 |
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 |
138 |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
139 |
uint32_t get_length(uint32_t row_offset= 0); |
140 |
uint32_t get_length(const unsigned char *ptr, uint32_t packlength, |
|
141 |
bool low_byte_first); |
|
142 |
uint32_t get_length(const unsigned char *ptr_arg); |
|
481
by Brian Aker
Remove all of uchar. |
143 |
void put_length(unsigned char *pos, uint32_t length); |
144 |
inline void get_ptr(unsigned char **str) |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
145 |
{
|
481
by Brian Aker
Remove all of uchar. |
146 |
memcpy(str,ptr+packlength,sizeof(unsigned char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
147 |
}
|
482
by Brian Aker
Remove uint. |
148 |
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 |
149 |
{
|
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
150 |
memcpy(str,ptr+packlength+row_offset,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
151 |
}
|
481
by Brian Aker
Remove all of uchar. |
152 |
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 |
153 |
{
|
154 |
memcpy(ptr,length,packlength); |
|
212.6.3
by Mats Kindahl
Removing deprecated functions from code and replacing them with C99 equivalents: |
155 |
memcpy(ptr+packlength,&data,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
156 |
}
|
481
by Brian Aker
Remove all of uchar. |
157 |
void set_ptr_offset(my_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 |
158 |
{
|
481
by Brian Aker
Remove all of uchar. |
159 |
unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
160 |
store_length(ptr_ofs, packlength, length); |
212.6.3
by Mats Kindahl
Removing deprecated functions from code and replacing them with C99 equivalents: |
161 |
memcpy(ptr_ofs+packlength,&data,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
162 |
}
|
481
by Brian Aker
Remove all of uchar. |
163 |
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 |
164 |
{
|
165 |
set_ptr_offset(0, length, data); |
|
166 |
}
|
|
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... |
167 |
uint32_t get_key_image(unsigned char *buff,uint32_t length); |
168 |
uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length); |
|
482
by Brian Aker
Remove uint. |
169 |
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 |
170 |
void sql_type(String &str) const; |
171 |
inline bool copy() |
|
172 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
173 |
unsigned char *tmp; |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
174 |
get_ptr(&tmp); |
175 |
if (value.copy((char*) tmp, get_length(), charset())) |
|
176 |
{
|
|
177 |
Field_blob::reset(); |
|
178 |
return 1; |
|
179 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
180 |
tmp=(unsigned char*) value.ptr(); |
212.6.3
by Mats Kindahl
Removing deprecated functions from code and replacing them with C99 equivalents: |
181 |
memcpy(ptr+packlength,&tmp,sizeof(char*)); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
182 |
return 0; |
183 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
184 |
virtual unsigned char *pack(unsigned char *to, const unsigned char *from, |
482
by Brian Aker
Remove uint. |
185 |
uint32_t max_length, bool low_byte_first); |
481
by Brian Aker
Remove all of uchar. |
186 |
unsigned char *pack_key(unsigned char *to, const unsigned char *from, |
482
by Brian Aker
Remove uint. |
187 |
uint32_t max_length, bool low_byte_first); |
481
by Brian Aker
Remove all of uchar. |
188 |
virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from, |
482
by Brian Aker
Remove uint. |
189 |
uint32_t param_data, bool low_byte_first); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
190 |
void free() { value.free(); } |
212.6.6
by Mats Kindahl
Removing redundant use of casts in drizzled/ for memcmp(), memcpy(), memset(), and memmove(). |
191 |
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 |
192 |
friend int field_conv(Field *to,Field *from); |
482
by Brian Aker
Remove uint. |
193 |
uint32_t size_of() const { return sizeof(*this); } |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
194 |
bool has_charset(void) const |
195 |
{ return charset() == &my_charset_bin ? false : true; } |
|
196 |
uint32_t max_display_length(); |
|
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
197 |
uint32_t is_equal(CreateField *new_field); |
1003.1.11
by Brian Aker
Remove dead in_read_set() from blob fields. |
198 |
|
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
199 |
private: |
481
by Brian Aker
Remove all of uchar. |
200 |
int do_save_field_metadata(unsigned char *first_byte); |
173.1.2
by Toru Maesaka
forgot to bzr-add new files in the previous push |
201 |
};
|
202 |
||
203 |
#endif
|
|
204 |