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