390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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
|
|
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 |
*/
|
|
1
by brian
clean slate |
19 |
|
20 |
/*
|
|
21 |
Because of the function new_field() all field classes that have static
|
|
22 |
variables must declare the size_of() member function.
|
|
23 |
*/
|
|
24 |
||
520.8.2
by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes. |
25 |
#ifndef DRIZZLED_FIELD_H
|
26 |
#define DRIZZLED_FIELD_H
|
|
27 |
||
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
28 |
#include "drizzled/sql_error.h" |
29 |
#include "drizzled/my_decimal.h" |
|
30 |
#include "drizzled/key_map.h" |
|
31 |
#include "drizzled/sql_bitmap.h" |
|
32 |
#include "drizzled/sql_list.h" |
|
33 |
#include "drizzled/structs.h" |
|
1241.9.61
by Monty Taylor
No more mystrings in drizzled/ |
34 |
#include "drizzled/charset_info.h" |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
35 |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
36 |
#include <string> |
1052.2.5
by Nathan Williams
Changed container from list to vector for CreateField::interval_list. There is never inserts into the middle of the container, only push_back. Per jaypipes suggestion. |
37 |
#include <vector> |
1
by brian
clean slate |
38 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
39 |
namespace drizzled |
40 |
{
|
|
41 |
||
1
by brian
clean slate |
42 |
#define DATETIME_DEC 6
|
173.1.9
by Toru Maesaka
ripped out DOUBLE and moved to field/ |
43 |
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
|
1091
by Brian Aker
Collection of patches from new-cleanup (includes asserts for field in debug) |
44 |
|
45 |
#ifdef DEBUG
|
|
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
46 |
#define ASSERT_COLUMN_MARKED_FOR_READ assert(!table || (table->read_set == NULL || isReadSet()))
|
47 |
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(!table || (table->write_set == NULL || isWriteSet()))
|
|
1091
by Brian Aker
Collection of patches from new-cleanup (includes asserts for field in debug) |
48 |
#else
|
49 |
#define ASSERT_COLUMN_MARKED_FOR_READ
|
|
50 |
#define ASSERT_COLUMN_MARKED_FOR_WRITE
|
|
51 |
#endif
|
|
173.1.9
by Toru Maesaka
ripped out DOUBLE and moved to field/ |
52 |
|
1241.9.51
by Monty Taylor
More mysys stuff out of headers. |
53 |
typedef struct st_typelib TYPELIB; |
54 |
||
205
by Brian Aker
uint32 -> uin32_t |
55 |
const uint32_t max_field_size= (uint32_t) 4294967295U; |
1
by brian
clean slate |
56 |
|
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
57 |
class SendField; |
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
58 |
class CreateField; |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
59 |
class TableShare; |
798.2.29
by Brian Aker
Detangle more of the session object |
60 |
class Field; |
1
by brian
clean slate |
61 |
struct st_cache_field; |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
62 |
|
1
by brian
clean slate |
63 |
int field_conv(Field *to,Field *from); |
64 |
||
438.1.13
by Brian Aker
uint cleanup. |
65 |
inline uint32_t get_enum_pack_length(int elements) |
1
by brian
clean slate |
66 |
{
|
67 |
return elements < 256 ? 1 : 2; |
|
68 |
}
|
|
69 |
||
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
70 |
/**
|
71 |
* Class representing a Field in a Table
|
|
72 |
*
|
|
73 |
* @details
|
|
74 |
*
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
75 |
* The value stored in the Field object is stored in the
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
76 |
* unsigned char pointer member variable called ptr. The
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
77 |
* val_xxx() methods retrieve this raw byte value and
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
78 |
* convert the byte into the appropriate output (int, decimal, etc).
|
79 |
*
|
|
80 |
* The store_xxx() methods take various input and convert
|
|
81 |
* the input into the raw bytes stored in the ptr member variable.
|
|
82 |
*/
|
|
1
by brian
clean slate |
83 |
class Field |
84 |
{
|
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
85 |
/* Prevent use of these */
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
86 |
Field(const Field&); |
1
by brian
clean slate |
87 |
void operator=(Field &); |
88 |
public: |
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
89 |
unsigned char *ptr; /**< Position to field in record. Stores raw field value */ |
90 |
unsigned char *null_ptr; /**< Byte where null_bit is */ |
|
91 |
||
92 |
/**
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
93 |
* Pointer to the Table object containing this Field
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
94 |
*
|
95 |
* @note You can use table->in_use as replacement for current_session member
|
|
96 |
* only inside of val_*() and store() members (e.g. you can't use it in cons)
|
|
97 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
98 |
Table *table; |
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
99 |
Table *orig_table; /**< Pointer to the original Table. @TODO What is "the original table"? */ |
100 |
const char **table_name; /**< Pointer to the name of the table. @TODO This is redundant with Table::table_name. */ |
|
101 |
const char *field_name; /**< Name of the field */ |
|
102 |
LEX_STRING comment; /**< A comment about the field */ |
|
103 |
||
104 |
/** The field is part of the following keys */
|
|
105 |
key_map key_start; |
|
106 |
key_map part_of_key; |
|
107 |
key_map part_of_key_not_clustered; |
|
108 |
key_map part_of_sortkey; |
|
109 |
||
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
110 |
/*
|
1259.5.4
by Stewart Smith
better reflect reality in why we have TIMESTAMP types around. |
111 |
We use three additional unireg types for TIMESTAMP for hysterical
|
112 |
raisins and limitations in the MySQL FRM file format.
|
|
113 |
||
114 |
A good TODO is to clean this up as we can support just about
|
|
115 |
anything in the table proto message now.
|
|
1
by brian
clean slate |
116 |
*/
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
117 |
enum utype |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
118 |
{
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
119 |
NONE, |
120 |
NEXT_NUMBER, |
|
121 |
TIMESTAMP_OLD_FIELD, |
|
122 |
TIMESTAMP_DN_FIELD, |
|
123 |
TIMESTAMP_UN_FIELD, |
|
124 |
TIMESTAMP_DNUN_FIELD
|
|
125 |
};
|
|
1
by brian
clean slate |
126 |
|
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
127 |
utype unireg_check; |
128 |
uint32_t field_length; /**< Length of this field in bytes */ |
|
129 |
uint32_t flags; |
|
130 |
uint16_t field_index; /**< Index of this Field in Table::fields array */ |
|
131 |
unsigned char null_bit; /**< Bit used to test null bit */ |
|
1
by brian
clean slate |
132 |
/**
|
133 |
If true, this field was created in create_tmp_field_from_item from a NULL
|
|
134 |
value. This means that the type of the field is just a guess, and the type
|
|
135 |
may be freely coerced to another type.
|
|
136 |
||
137 |
@see create_tmp_field_from_item
|
|
138 |
@see Item_type_holder::get_real_type
|
|
139 |
*/
|
|
140 |
bool is_created_from_null_item; |
|
141 |
||
1241.9.51
by Monty Taylor
More mysys stuff out of headers. |
142 |
static void *operator new(size_t size); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
143 |
static void *operator new(size_t size, memory::Root *mem_root); |
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
144 |
static void operator delete(void *, size_t) |
1241.9.51
by Monty Taylor
More mysys stuff out of headers. |
145 |
{ } |
1055.2.4
by Jay Pipes
Style, indentation, and doxygen/documentation cleanup on Field class. Removal of dead methods in Field such as do_last_null_byte(), last_null_byte() and anonymous enum with LAST_NULL_BYTE_UNDEF... |
146 |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
147 |
Field(unsigned char *ptr_arg, |
148 |
uint32_t length_arg, |
|
149 |
unsigned char *null_ptr_arg, |
|
150 |
unsigned char null_bit_arg, |
|
151 |
utype unireg_check_arg, |
|
1
by brian
clean slate |
152 |
const char *field_name_arg); |
153 |
virtual ~Field() {} |
|
154 |
/* Store functions returns 1 on overflow and -1 on fatal error */
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
155 |
virtual int store(const char *to, |
156 |
uint32_t length, |
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
157 |
const CHARSET_INFO * const cs)=0; |
158 |
virtual int store(double nr)=0; |
|
159 |
virtual int store(int64_t nr, bool unsigned_val)=0; |
|
160 |
virtual int store_decimal(const my_decimal *d)=0; |
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
161 |
int store(const char *to, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
162 |
uint32_t length, |
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
163 |
const CHARSET_INFO * const cs, |
164 |
enum_check_fields check_level); |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
165 |
/**
|
166 |
This is called when storing a date in a string.
|
|
167 |
||
168 |
@note
|
|
169 |
Needs to be changed if/when we want to support different time formats.
|
|
170 |
*/
|
|
171 |
virtual int store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type t_type); |
|
1
by brian
clean slate |
172 |
virtual double val_real(void)=0; |
152
by Brian Aker
longlong replacement |
173 |
virtual int64_t val_int(void)=0; |
1
by brian
clean slate |
174 |
virtual my_decimal *val_decimal(my_decimal *); |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
175 |
inline String *val_str(String *str) |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
176 |
{
|
177 |
return val_str(str, str); |
|
178 |
}
|
|
1
by brian
clean slate |
179 |
/*
|
180 |
val_str(buf1, buf2) gets two buffers and should use them as follows:
|
|
181 |
if it needs a temp buffer to convert result to string - use buf1
|
|
182 |
example Field_tiny::val_str()
|
|
183 |
if the value exists as a string already - use buf2
|
|
241
by Brian Aker
First pass of CHAR removal. |
184 |
example Field_varstring::val_str() (???)
|
1
by brian
clean slate |
185 |
consequently, buf2 may be created as 'String buf;' - no memory
|
186 |
will be allocated for it. buf1 will be allocated to hold a
|
|
187 |
value if it's too small. Using allocated buffer for buf2 may result in
|
|
188 |
an unnecessary free (and later, may be an alloc).
|
|
189 |
This trickery is used to decrease a number of malloc calls.
|
|
190 |
*/
|
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
191 |
virtual String *val_str(String*, String *)=0; |
1
by brian
clean slate |
192 |
/*
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
193 |
str_needs_quotes() returns true if the value returned by val_str() needs
|
1
by brian
clean slate |
194 |
to be quoted when used in constructing an SQL query.
|
195 |
*/
|
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
196 |
virtual bool str_needs_quotes() { return false; } |
1
by brian
clean slate |
197 |
virtual Item_result result_type () const=0; |
198 |
virtual Item_result cmp_type () const { return result_type(); } |
|
199 |
virtual Item_result cast_to_int_type () const { return result_type(); } |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
200 |
/**
|
201 |
Check whether a field type can be partially indexed by a key.
|
|
202 |
||
203 |
This is a static method, rather than a virtual function, because we need
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
204 |
to check the type of a non-Field in alter_table().
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
205 |
|
206 |
@param type field type
|
|
207 |
||
208 |
@retval
|
|
209 |
true Type can have a prefixed key
|
|
210 |
@retval
|
|
211 |
false Type can not have a prefixed key
|
|
212 |
*/
|
|
1
by brian
clean slate |
213 |
static bool type_can_have_key_part(enum_field_types); |
1055.2.9
by Jay Pipes
Removes dead get_blob_type_from_length() function. We only have one type of BLOB now... |
214 |
/**
|
215 |
Return type of which can carry value of both given types in UNION result.
|
|
216 |
||
217 |
@param a type for merging
|
|
218 |
@param b type for merging
|
|
219 |
||
220 |
@retval
|
|
221 |
type of field
|
|
222 |
*/
|
|
1
by brian
clean slate |
223 |
static enum_field_types field_type_merge(enum_field_types, enum_field_types); |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
224 |
|
225 |
/**
|
|
226 |
Detect Item_result by given field type of UNION merge result.
|
|
227 |
||
228 |
@param field_type given field type
|
|
229 |
||
230 |
@return
|
|
231 |
Item_result (type of internal MySQL expression result)
|
|
232 |
*/
|
|
1
by brian
clean slate |
233 |
static Item_result result_merge_type(enum_field_types); |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
234 |
|
235 |
virtual bool eq(Field *field); |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
236 |
/**
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
237 |
* Returns true if the fields are equally defined
|
238 |
*
|
|
239 |
* @retval
|
|
240 |
* true This Field is equally defined to supplied Field
|
|
241 |
* @retval
|
|
242 |
* false This Field is NOT equally defined to supplied Field
|
|
243 |
*/
|
|
1
by brian
clean slate |
244 |
virtual bool eq_def(Field *field); |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
245 |
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
246 |
/**
|
247 |
* Returns size (in bytes) used to store field data in memory
|
|
248 |
* (i.e. it returns the maximum size of the field in a row of the table,
|
|
249 |
* which is located in RAM).
|
|
250 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
251 |
virtual uint32_t pack_length() const; |
1
by brian
clean slate |
252 |
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
253 |
/**
|
254 |
* Returns size (in bytes) used to store field data on
|
|
255 |
* storage (i.e. it returns the maximal size of the field in a row of the
|
|
256 |
* table, which is located on disk).
|
|
257 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
258 |
virtual uint32_t pack_length_in_rec() const; |
1
by brian
clean slate |
259 |
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
260 |
/**
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
261 |
* Return the "real size" of the data in memory.
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
262 |
* For varstrings, this does _not_ include the length bytes.
|
263 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
264 |
virtual uint32_t data_length(); |
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
265 |
/**
|
266 |
* Returns the number of bytes actually used to store the data
|
|
267 |
* of the field. So for a varstring it includes both lenght byte(s) and
|
|
268 |
* string data, and anything after data_length() bytes are unused.
|
|
269 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
270 |
virtual uint32_t used_length(); |
271 |
virtual uint32_t sort_length() const; |
|
1
by brian
clean slate |
272 |
|
273 |
/**
|
|
274 |
Get the maximum size of the data in packed format.
|
|
275 |
||
276 |
@return Maximum data length of the field when packed using the
|
|
277 |
Field::pack() function.
|
|
278 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
279 |
virtual uint32_t max_data_length() const; |
280 |
virtual int reset(void); |
|
281 |
virtual void reset_fields(); |
|
282 |
virtual void set_default(); |
|
283 |
virtual bool binary() const; |
|
284 |
virtual bool zero_pack() const; |
|
285 |
virtual enum ha_base_keytype key_type() const; |
|
286 |
virtual uint32_t key_length() const; |
|
1
by brian
clean slate |
287 |
virtual enum_field_types type() const =0; |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
288 |
virtual enum_field_types real_type() const; |
481
by Brian Aker
Remove all of uchar. |
289 |
inline int cmp(const unsigned char *str) { return cmp(ptr,str); } |
290 |
virtual int cmp_max(const unsigned char *a, const unsigned char *b, |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
291 |
uint32_t max_len); |
481
by Brian Aker
Remove all of uchar. |
292 |
virtual int cmp(const unsigned char *,const unsigned char *)=0; |
293 |
virtual int cmp_binary(const unsigned char *a,const unsigned char *b, |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
294 |
uint32_t max_length=UINT32_MAX); |
295 |
virtual int cmp_offset(uint32_t row_offset); |
|
296 |
virtual int cmp_binary_offset(uint32_t row_offset); |
|
297 |
virtual int key_cmp(const unsigned char *a,const unsigned char *b); |
|
298 |
virtual int key_cmp(const unsigned char *str, uint32_t length); |
|
299 |
virtual uint32_t decimals() const; |
|
300 |
||
1
by brian
clean slate |
301 |
/*
|
302 |
Caller beware: sql_type can change str.Ptr, so check
|
|
303 |
ptr() to see if it changed if you are using your own buffer
|
|
304 |
in str and restore it with set() if needed
|
|
305 |
*/
|
|
306 |
virtual void sql_type(String &str) const =0; |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
307 |
|
308 |
// For new field
|
|
309 |
virtual uint32_t size_of() const =0; |
|
310 |
||
1122.2.12
by Monty Taylor
Removed the silly my_ptrdiff_t typedef. |
311 |
bool is_null(ptrdiff_t row_offset= 0); |
312 |
bool is_real_null(ptrdiff_t row_offset= 0); |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
313 |
bool is_null_in_record(const unsigned char *record); |
1055.2.9
by Jay Pipes
Removes dead get_blob_type_from_length() function. We only have one type of BLOB now... |
314 |
bool is_null_in_record_with_offset(ptrdiff_t offset); |
315 |
void set_null(ptrdiff_t row_offset= 0); |
|
316 |
void set_notnull(ptrdiff_t row_offset= 0); |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
317 |
bool maybe_null(void); |
318 |
bool real_maybe_null(void); |
|
1
by brian
clean slate |
319 |
|
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
320 |
virtual void make_field(SendField *); |
481
by Brian Aker
Remove all of uchar. |
321 |
virtual void sort_string(unsigned char *buff,uint32_t length)=0; |
438.1.13
by Brian Aker
uint cleanup. |
322 |
virtual bool optimize_range(uint32_t idx, uint32_t part); |
1055.2.9
by Jay Pipes
Removes dead get_blob_type_from_length() function. We only have one type of BLOB now... |
323 |
/**
|
324 |
* Returns true for fields which, when compared with constant
|
|
325 |
* items, can be casted to int64_t. In this case we will at 'fix_fields'
|
|
326 |
* stage cast the constant items to int64_ts and at the execution stage
|
|
327 |
* use field->val_int() for comparison. Used to optimize clauses like
|
|
328 |
* 'a_column BETWEEN date_const AND date_const'.
|
|
329 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
330 |
virtual bool can_be_compared_as_int64_t() const |
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
331 |
{
|
332 |
return false; |
|
333 |
}
|
|
1
by brian
clean slate |
334 |
virtual void free() {} |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
335 |
virtual Field *new_field(memory::Root *root, |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
336 |
Table *new_table, |
1
by brian
clean slate |
337 |
bool keep_type); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
338 |
virtual Field *new_key_field(memory::Root *root, Table *new_table, |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
339 |
unsigned char *new_ptr, |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
340 |
unsigned char *new_null_ptr, |
438.1.13
by Brian Aker
uint cleanup. |
341 |
uint32_t new_null_bit); |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
342 |
/** This is used to generate a field in Table from TableShare */
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
343 |
Field *clone(memory::Root *mem_root, Table *new_table); |
481
by Brian Aker
Remove all of uchar. |
344 |
inline void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg) |
1
by brian
clean slate |
345 |
{
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
346 |
ptr= ptr_arg; |
347 |
null_ptr= null_ptr_arg; |
|
348 |
null_bit= null_bit_arg; |
|
1
by brian
clean slate |
349 |
}
|
481
by Brian Aker
Remove all of uchar. |
350 |
inline void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; } |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
351 |
virtual void move_field_offset(ptrdiff_t ptr_diff) |
1
by brian
clean slate |
352 |
{
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
353 |
ptr= ADD_TO_PTR(ptr,ptr_diff, unsigned char*); |
1
by brian
clean slate |
354 |
if (null_ptr) |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
355 |
null_ptr= ADD_TO_PTR(null_ptr,ptr_diff,unsigned char*); |
1
by brian
clean slate |
356 |
}
|
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... |
357 |
virtual void get_image(unsigned char *buff, uint32_t length, const CHARSET_INFO * const) |
358 |
{
|
|
359 |
memcpy(buff,ptr,length); |
|
360 |
}
|
|
361 |
virtual void get_image(std::basic_string<unsigned char> &buff, uint32_t length, const CHARSET_INFO * const) |
|
362 |
{
|
|
363 |
buff.append(ptr,length); |
|
364 |
}
|
|
365 |
virtual void set_image(const unsigned char *buff,uint32_t length, const CHARSET_INFO * const) |
|
366 |
{
|
|
367 |
memcpy(ptr,buff,length); |
|
368 |
}
|
|
1
by brian
clean slate |
369 |
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
370 |
/**
|
371 |
* Copy a field part into an output buffer.
|
|
372 |
*
|
|
373 |
* @details
|
|
374 |
*
|
|
375 |
* This function makes a copy of field part of size equal to or
|
|
376 |
* less than "length" parameter value.
|
|
377 |
* For fields of string types (VARCHAR, TEXT) the rest of buffer
|
|
378 |
* is padded by zero byte.
|
|
379 |
*
|
|
380 |
* @param output buffer
|
|
381 |
* @param output buffer size
|
|
382 |
*
|
|
383 |
* @note
|
|
384 |
*
|
|
385 |
* For variable length character fields (i.e. UTF-8) the "length"
|
|
386 |
* parameter means a number of output buffer bytes as if all field
|
|
387 |
* characters have maximal possible size (mbmaxlen). In the other words,
|
|
388 |
* "length" parameter is a number of characters multiplied by
|
|
389 |
* field_charset->mbmaxlen.
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
390 |
*
|
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
391 |
* @retval
|
392 |
* Number of copied bytes (excluding padded zero bytes -- see above).
|
|
393 |
*/
|
|
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... |
394 |
virtual uint32_t get_key_image(unsigned char *buff, uint32_t length) |
1
by brian
clean slate |
395 |
{
|
396 |
get_image(buff, length, &my_charset_bin); |
|
397 |
return length; |
|
398 |
}
|
|
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... |
399 |
virtual uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length) |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
400 |
{
|
401 |
get_image(buff, length, &my_charset_bin); |
|
402 |
return length; |
|
403 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
404 |
virtual void set_key_image(const unsigned char *buff,uint32_t length) |
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... |
405 |
{
|
406 |
set_image(buff,length, &my_charset_bin); |
|
407 |
}
|
|
438.1.13
by Brian Aker
uint cleanup. |
408 |
inline int64_t val_int_offset(uint32_t row_offset) |
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
409 |
{
|
410 |
ptr+=row_offset; |
|
411 |
int64_t tmp=val_int(); |
|
412 |
ptr-=row_offset; |
|
413 |
return tmp; |
|
414 |
}
|
|
415 |
||
416 |
inline int64_t val_int(const unsigned char *new_ptr) |
|
417 |
{
|
|
418 |
unsigned char *old_ptr= ptr; |
|
419 |
int64_t return_value; |
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
420 |
ptr= const_cast<unsigned char*>(new_ptr); |
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
421 |
return_value= val_int(); |
422 |
ptr= old_ptr; |
|
423 |
return return_value; |
|
424 |
}
|
|
425 |
inline String *val_str(String *str, const unsigned char *new_ptr) |
|
426 |
{
|
|
427 |
unsigned char *old_ptr= ptr; |
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
428 |
ptr= const_cast<unsigned char*>(new_ptr); |
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
429 |
val_str(str); |
430 |
ptr= old_ptr; |
|
431 |
return str; |
|
432 |
}
|
|
433 |
||
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
434 |
/**
|
435 |
Pack the field into a format suitable for storage and transfer.
|
|
436 |
||
437 |
To implement packing functionality, only the virtual function
|
|
438 |
should be overridden. The other functions are just convenience
|
|
439 |
functions and hence should not be overridden.
|
|
440 |
||
441 |
The value of <code>low_byte_first</code> is dependent on how the
|
|
442 |
packed data is going to be used: for local use, e.g., temporary
|
|
443 |
store on disk or in memory, use the native format since that is
|
|
444 |
faster. For data that is going to be transfered to other machines
|
|
445 |
(e.g., when writing data to the binary log), data should always be
|
|
446 |
stored in little-endian format.
|
|
447 |
||
448 |
@note The default method for packing fields just copy the raw bytes
|
|
449 |
of the record into the destination, but never more than
|
|
450 |
<code>max_length</code> characters.
|
|
451 |
||
452 |
@param to
|
|
453 |
Pointer to memory area where representation of field should be put.
|
|
454 |
||
455 |
@param from
|
|
456 |
Pointer to memory area where record representation of field is
|
|
457 |
stored.
|
|
458 |
||
459 |
@param max_length
|
|
460 |
Maximum length of the field, as given in the column definition. For
|
|
461 |
example, for <code>CHAR(1000)</code>, the <code>max_length</code>
|
|
462 |
is 1000. This information is sometimes needed to decide how to pack
|
|
463 |
the data.
|
|
464 |
||
465 |
@param low_byte_first
|
|
466 |
@c true if integers should be stored little-endian, @c false if
|
|
467 |
native format should be used. Note that for little-endian machines,
|
|
468 |
the value of this flag is a moot point since the native format is
|
|
469 |
little-endian.
|
|
470 |
*/
|
|
779.3.16
by Monty Taylor
Some Sun warning fixes. |
471 |
virtual unsigned char *pack(unsigned char *to, |
472 |
const unsigned char *from, |
|
473 |
uint32_t max_length, |
|
474 |
bool low_byte_first); |
|
475 |
||
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
476 |
unsigned char *pack(unsigned char *to, const unsigned char *from); |
1
by brian
clean slate |
477 |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
478 |
/**
|
479 |
Unpack a field from row data.
|
|
480 |
||
481 |
This method is used to unpack a field from a master whose size of
|
|
482 |
the field is less than that of the slave.
|
|
483 |
||
484 |
The <code>param_data</code> parameter is a two-byte integer (stored
|
|
485 |
in the least significant 16 bits of the unsigned integer) usually
|
|
486 |
consisting of two parts: the real type in the most significant byte
|
|
487 |
and a original pack length in the least significant byte.
|
|
488 |
||
489 |
The exact layout of the <code>param_data</code> field is given by
|
|
490 |
the <code>Table_map_log_event::save_field_metadata()</code>.
|
|
491 |
||
492 |
This is the default method for unpacking a field. It just copies
|
|
493 |
the memory block in byte order (of original pack length bytes or
|
|
494 |
length of field, whichever is smaller).
|
|
495 |
||
496 |
@param to Destination of the data
|
|
497 |
@param from Source of the data
|
|
498 |
@param param_data Real type and original pack length of the field
|
|
499 |
data
|
|
500 |
||
501 |
@param low_byte_first
|
|
502 |
If this flag is @c true, all composite entities (e.g., lengths)
|
|
503 |
should be unpacked in little-endian format; otherwise, the entities
|
|
504 |
are unpacked in native order.
|
|
505 |
||
506 |
@return New pointer into memory based on from + length of the data
|
|
507 |
*/
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
508 |
virtual const unsigned char *unpack(unsigned char* to, |
509 |
const unsigned char *from, |
|
510 |
uint32_t param_data, |
|
511 |
bool low_byte_first); |
|
1
by brian
clean slate |
512 |
/**
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
513 |
@overload Field::unpack(unsigned char*, const unsigned char*,
|
514 |
uint32_t, bool)
|
|
1
by brian
clean slate |
515 |
*/
|
779.3.18
by Monty Taylor
Cleaned up warnings up through innodb. |
516 |
const unsigned char *unpack(unsigned char* to, |
517 |
const unsigned char *from); |
|
1
by brian
clean slate |
518 |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
519 |
virtual unsigned char *pack_key(unsigned char* to, |
520 |
const unsigned char *from, |
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
521 |
uint32_t max_length, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
522 |
bool low_byte_first) |
1
by brian
clean slate |
523 |
{
|
524 |
return pack(to, from, max_length, low_byte_first); |
|
525 |
}
|
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
526 |
virtual const unsigned char *unpack_key(unsigned char* to, |
527 |
const unsigned char *from, |
|
528 |
uint32_t max_length, |
|
529 |
bool low_byte_first) |
|
1
by brian
clean slate |
530 |
{
|
531 |
return unpack(to, from, max_length, low_byte_first); |
|
532 |
}
|
|
438.1.13
by Brian Aker
uint cleanup. |
533 |
virtual uint32_t max_packed_col_length(uint32_t max_length) |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
534 |
{
|
535 |
return max_length; |
|
536 |
}
|
|
1
by brian
clean slate |
537 |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
538 |
inline uint32_t offset(unsigned char *record) |
1
by brian
clean slate |
539 |
{
|
438.1.13
by Brian Aker
uint cleanup. |
540 |
return (uint32_t) (ptr - record); |
1
by brian
clean slate |
541 |
}
|
542 |
void copy_from_tmp(int offset); |
|
438.1.13
by Brian Aker
uint cleanup. |
543 |
uint32_t fill_cache_field(struct st_cache_field *copy); |
544 |
virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
545 |
virtual bool get_time(DRIZZLE_TIME *ltime); |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
546 |
virtual const CHARSET_INFO *charset(void) const { return &my_charset_bin; } |
547 |
virtual const CHARSET_INFO *sort_charset(void) const { return charset(); } |
|
51.1.58
by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another |
548 |
virtual bool has_charset(void) const { return false; } |
644
by Brian Aker
Clean up warnings for Solaris. |
549 |
virtual void set_charset(const CHARSET_INFO * const) |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
550 |
{}
|
1
by brian
clean slate |
551 |
virtual enum Derivation derivation(void) const |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
552 |
{
|
553 |
return DERIVATION_IMPLICIT; |
|
554 |
}
|
|
644
by Brian Aker
Clean up warnings for Solaris. |
555 |
virtual void set_derivation(enum Derivation) |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
556 |
{}
|
557 |
/**
|
|
558 |
Produce warning or note about data saved into field.
|
|
559 |
||
560 |
@param level - level of message (Note/Warning/Error)
|
|
561 |
@param code - error code of message to be produced
|
|
562 |
@param cuted_increment - whenever we should increase cut fields count or not
|
|
563 |
||
564 |
@note
|
|
565 |
This function won't produce warning and increase cut fields counter
|
|
566 |
if count_cuted_fields == CHECK_FIELD_IGNORE for current thread.
|
|
567 |
||
568 |
if count_cuted_fields == CHECK_FIELD_IGNORE then we ignore notes.
|
|
569 |
This allows us to avoid notes in optimisation, like convert_constant_item().
|
|
570 |
||
571 |
@retval
|
|
572 |
1 if count_cuted_fields == CHECK_FIELD_IGNORE and error level is not NOTE
|
|
573 |
@retval
|
|
574 |
0 otherwise
|
|
575 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
576 |
bool set_warning(DRIZZLE_ERROR::enum_warning_level, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
577 |
unsigned int code, |
1
by brian
clean slate |
578 |
int cuted_increment); |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
579 |
/**
|
580 |
Produce warning or note about datetime string data saved into field.
|
|
581 |
||
582 |
@param level level of message (Note/Warning/Error)
|
|
583 |
@param code error code of message to be produced
|
|
584 |
@param str string value which we tried to save
|
|
585 |
@param str_length length of string which we tried to save
|
|
586 |
@param ts_type type of datetime value (datetime/date/time)
|
|
587 |
@param cuted_increment whenever we should increase cut fields count or not
|
|
588 |
||
589 |
@note
|
|
590 |
This function will always produce some warning but won't increase cut
|
|
591 |
fields counter if count_cuted_fields ==FIELD_CHECK_IGNORE for current
|
|
592 |
thread.
|
|
593 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
594 |
void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
595 |
uint32_t code, |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
596 |
const char *str, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
597 |
uint32_t str_len, |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
598 |
enum enum_drizzle_timestamp_type ts_type, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
599 |
int cuted_increment); |
600 |
/**
|
|
601 |
Produce warning or note about integer datetime value saved into field.
|
|
602 |
||
603 |
@param level level of message (Note/Warning/Error)
|
|
604 |
@param code error code of message to be produced
|
|
605 |
@param nr numeric value which we tried to save
|
|
606 |
@param ts_type type of datetime value (datetime/date/time)
|
|
607 |
@param cuted_increment whenever we should increase cut fields count or not
|
|
608 |
||
609 |
@note
|
|
610 |
This function will always produce some warning but won't increase cut
|
|
611 |
fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
|
|
612 |
thread.
|
|
613 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
614 |
void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
615 |
uint32_t code, |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
616 |
int64_t nr, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
617 |
enum enum_drizzle_timestamp_type ts_type, |
618 |
int cuted_increment); |
|
619 |
/**
|
|
620 |
Produce warning or note about double datetime data saved into field.
|
|
621 |
||
622 |
@param level level of message (Note/Warning/Error)
|
|
623 |
@param code error code of message to be produced
|
|
624 |
@param nr double value which we tried to save
|
|
625 |
@param ts_type type of datetime value (datetime/date/time)
|
|
626 |
||
627 |
@note
|
|
628 |
This function will always produce some warning but won't increase cut
|
|
629 |
fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
|
|
630 |
thread.
|
|
631 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
632 |
void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
633 |
const uint32_t code, |
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
634 |
double nr, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
635 |
enum enum_drizzle_timestamp_type ts_type); |
1
by brian
clean slate |
636 |
inline bool check_overflow(int op_result) |
637 |
{
|
|
638 |
return (op_result == E_DEC_OVERFLOW); |
|
639 |
}
|
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
640 |
/**
|
641 |
Process decimal library return codes and issue warnings for overflow and
|
|
642 |
truncation.
|
|
643 |
||
644 |
@param op_result decimal library return code (E_DEC_* see include/decimal.h)
|
|
645 |
||
646 |
@retval
|
|
647 |
E_DEC_OVERFLOW there was overflow
|
|
648 |
E_DEC_TRUNCATED there was truncation
|
|
649 |
@retval
|
|
650 |
0 no error or there was some other error except overflow or truncation
|
|
651 |
*/
|
|
1
by brian
clean slate |
652 |
int warn_if_overflow(int op_result); |
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
653 |
void init(Table *table_arg); |
1
by brian
clean slate |
654 |
|
655 |
/* maximum possible display length */
|
|
205
by Brian Aker
uint32 -> uin32_t |
656 |
virtual uint32_t max_display_length()= 0; |
1
by brian
clean slate |
657 |
|
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
658 |
virtual uint32_t is_equal(CreateField *new_field); |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
659 |
/**
|
660 |
Conversion from decimal to int64_t with checking overflow and
|
|
661 |
setting correct value (min/max) in case of overflow.
|
|
662 |
||
663 |
@param val value which have to be converted
|
|
664 |
@param unsigned_flag type of integer in which we convert val
|
|
665 |
@param err variable to pass error code
|
|
666 |
||
667 |
@return
|
|
668 |
value converted from val
|
|
669 |
*/
|
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
670 |
int64_t convert_decimal2int64_t(const my_decimal *val, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
671 |
bool unsigned_flag, |
672 |
int *err); |
|
1
by brian
clean slate |
673 |
/* The max. number of characters */
|
205
by Brian Aker
uint32 -> uin32_t |
674 |
inline uint32_t char_length() const |
1
by brian
clean slate |
675 |
{
|
676 |
return field_length / charset()->mbmaxlen; |
|
677 |
}
|
|
678 |
||
679 |
inline enum column_format_type column_format() const |
|
680 |
{
|
|
681 |
return (enum column_format_type) |
|
682 |
((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK); |
|
683 |
}
|
|
684 |
||
685 |
/* Hash value */
|
|
290
by Brian Aker
Update for ulong change over. |
686 |
virtual void hash(uint32_t *nr, uint32_t *nr2); |
520.1.21
by Brian Aker
THD -> Session rename |
687 |
friend bool reopen_table(Session *,Table *,bool); |
1052.2.7
by Nathan Williams
Merged trunk and resolved conflicts. |
688 |
|
1052.2.2
by Nathan Williams
No actual code changes. Changed Copy_field to CopyField, to reflect the coding standards. |
689 |
friend class CopyField; |
1
by brian
clean slate |
690 |
friend class Item_avg_field; |
691 |
friend class Item_std_field; |
|
692 |
friend class Item_sum_num; |
|
693 |
friend class Item_sum_sum; |
|
694 |
friend class Item_sum_str; |
|
695 |
friend class Item_sum_count; |
|
696 |
friend class Item_sum_avg; |
|
697 |
friend class Item_sum_std; |
|
698 |
friend class Item_sum_min; |
|
699 |
friend class Item_sum_max; |
|
700 |
friend class Item_func_group_concat; |
|
701 |
||
1003.1.9
by Brian Aker
Patches for Jay (aka name changes) |
702 |
bool isReadSet(); |
703 |
bool isWriteSet(); |
|
1089.1.3
by Brian Aker
Fix protobuf to release memory. Add in assert() for wrong column usage. Fix |
704 |
void setReadSet(bool arg= true); |
705 |
void setWriteSet(bool arg= true); |
|
1
by brian
clean slate |
706 |
};
|
707 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
708 |
} /* namespace drizzled */ |
709 |
||
710 |
/** @TODO Why is this in the middle of the file???*/
|
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
711 |
#include "drizzled/create_field.h" |
712 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
713 |
namespace drizzled |
714 |
{
|
|
715 |
||
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
716 |
/**
|
717 |
* A class for sending field information to a client.
|
|
718 |
*
|
|
719 |
* @details
|
|
720 |
*
|
|
721 |
* Send_field is basically a stripped-down POD class for
|
|
722 |
* representing basic information about a field...
|
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
723 |
*/
|
1241.3.2
by Trond Norbye
Cleanup: use c++ style casting |
724 |
class SendField |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
725 |
{
|
726 |
public: |
|
1
by brian
clean slate |
727 |
const char *db_name; |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
728 |
const char *table_name; |
729 |
const char *org_table_name; |
|
730 |
const char *col_name; |
|
731 |
const char *org_col_name; |
|
290
by Brian Aker
Update for ulong change over. |
732 |
uint32_t length; |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
733 |
uint32_t charsetnr; |
734 |
uint32_t flags; |
|
735 |
uint32_t decimals; |
|
1
by brian
clean slate |
736 |
enum_field_types type; |
1052.2.4
by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards. |
737 |
SendField() {} |
1
by brian
clean slate |
738 |
};
|
739 |
||
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
740 |
/**
|
741 |
* A class for quick copying data to fields
|
|
742 |
*/
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
743 |
class CopyField :public memory::SqlAlloc |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
744 |
{
|
1
by brian
clean slate |
745 |
/**
|
746 |
Convenience definition of a copy function returned by
|
|
747 |
get_copy_func.
|
|
748 |
*/
|
|
1052.2.2
by Nathan Williams
No actual code changes. Changed Copy_field to CopyField, to reflect the coding standards. |
749 |
typedef void Copy_func(CopyField*); |
1
by brian
clean slate |
750 |
Copy_func *get_copy_func(Field *to, Field *from); |
751 |
public: |
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
752 |
unsigned char *from_ptr; |
753 |
unsigned char *to_ptr; |
|
754 |
unsigned char *from_null_ptr; |
|
755 |
unsigned char *to_null_ptr; |
|
274
by Brian Aker
my_bool conversion in Table |
756 |
bool *null_row; |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
757 |
uint32_t from_bit; |
758 |
uint32_t to_bit; |
|
759 |
uint32_t from_length; |
|
760 |
uint32_t to_length; |
|
761 |
Field *from_field; |
|
762 |
Field *to_field; |
|
1
by brian
clean slate |
763 |
String tmp; // For items |
764 |
||
1052.2.2
by Nathan Williams
No actual code changes. Changed Copy_field to CopyField, to reflect the coding standards. |
765 |
CopyField() {} |
766 |
~CopyField() {} |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
767 |
void set(Field *to,Field *from,bool save); // Field to field |
481
by Brian Aker
Remove all of uchar. |
768 |
void set(unsigned char *to,Field *from); // Field to string |
1052.2.2
by Nathan Williams
No actual code changes. Changed Copy_field to CopyField, to reflect the coding standards. |
769 |
void (*do_copy)(CopyField *); |
770 |
void (*do_copy2)(CopyField *); // Used to handle null values |
|
1
by brian
clean slate |
771 |
};
|
772 |
||
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
773 |
Field *make_field(TableShare *share, |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
774 |
memory::Root *root, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
775 |
unsigned char *ptr, |
776 |
uint32_t field_length, |
|
1119.9.10
by Jay Pipes
Removes FIELDFLAG_MAYBE_NULL and f_maybe_null() macro. |
777 |
bool is_nullable, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
778 |
unsigned char *null_pos, |
779 |
unsigned char null_bit, |
|
1119.9.22
by Stewart Smith
fix up decimals type to be uint8_t throughout and check that value in the proto is valid for what the server can currently handle |
780 |
uint8_t decimals, |
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
781 |
enum_field_types field_type, |
575.4.7
by Monty Taylor
More header cleanup. |
782 |
const CHARSET_INFO * cs, |
783 |
Field::utype unireg_check, |
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
784 |
TYPELIB *interval, |
785 |
const char *field_name); |
|
575.4.7
by Monty Taylor
More header cleanup. |
786 |
|
438.1.13
by Brian Aker
uint cleanup. |
787 |
uint32_t pack_length_to_packflag(uint32_t type); |
205
by Brian Aker
uint32 -> uin32_t |
788 |
uint32_t calc_pack_length(enum_field_types type,uint32_t length); |
1
by brian
clean slate |
789 |
int set_field_to_null(Field *field); |
790 |
int set_field_to_null_with_conversions(Field *field, bool no_conversions); |
|
791 |
||
1055.2.7
by Jay Pipes
More documentation cleanup for Field class |
792 |
/**
|
793 |
* Tests if the given string contains important data:
|
|
794 |
* not spaces for character string, or any data for binary string.
|
|
795 |
*
|
|
796 |
* @param pointer to the character set to use
|
|
797 |
* @param String to test
|
|
798 |
* @param String end
|
|
799 |
*
|
|
800 |
* @retval
|
|
801 |
* false - If string does not have important data
|
|
802 |
* @retval
|
|
803 |
* true - If string has some important data
|
|
804 |
*/
|
|
1055.2.6
by Jay Pipes
Style cleanup in field.cc and move documentation into Field class in header file. |
805 |
bool test_if_important_data(const CHARSET_INFO * const cs, |
806 |
const char *str, |
|
807 |
const char *strend); |
|
520.8.2
by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes. |
808 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
809 |
} /* namespace drizzled */ |
810 |
||
520.8.2
by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes. |
811 |
#endif /* DRIZZLED_FIELD_H */ |