~drizzle-trunk/drizzle/development

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