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