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