~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

  • Committer: Brian Aker
  • Date: 2009-12-08 23:37:35 UTC
  • mfrom: (1192.3.82 pandora-build)
  • mto: This revision was merged to the branch mainline in revision 1241.
  • Revision ID: brian@gaz-20091208233735-6zfhecyxizlw8bub
Merge range fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
22
22
  variables must declare the size_of() member function.
23
23
*/
24
24
 
25
 
 
26
 
 
27
25
#ifndef DRIZZLED_FIELD_H
28
26
#define DRIZZLED_FIELD_H
29
27
 
30
28
#include "drizzled/sql_error.h"
31
 
#include "drizzled/type/decimal.h"
 
29
#include "drizzled/my_decimal.h"
32
30
#include "drizzled/key_map.h"
 
31
#include "drizzled/sql_bitmap.h"
33
32
#include "drizzled/sql_list.h"
34
33
#include "drizzled/structs.h"
35
 
#include "drizzled/charset_info.h"
36
 
#include "drizzled/item_result.h"
37
 
#include "drizzled/charset_info.h"
38
34
 
39
35
#include <string>
40
36
#include <vector>
41
37
 
42
 
#include "drizzled/visibility.h"
43
 
 
44
 
namespace drizzled
45
 
{
46
 
 
47
38
#define DATETIME_DEC                     6
48
39
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
49
40
 
50
41
#ifdef DEBUG
51
 
#define ASSERT_COLUMN_MARKED_FOR_READ assert(!getTable() || (getTable()->read_set == NULL || isReadSet()))
52
 
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(!getTable() || (getTable()->write_set == NULL || isWriteSet()))
 
42
#define ASSERT_COLUMN_MARKED_FOR_READ assert(!table || (table->read_set == NULL || isReadSet()))
 
43
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(!table || (table->write_set == NULL || isWriteSet()))
53
44
#else
54
 
#define ASSERT_COLUMN_MARKED_FOR_READ assert(getTable())
55
 
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(getTable())
 
45
#define ASSERT_COLUMN_MARKED_FOR_READ
 
46
#define ASSERT_COLUMN_MARKED_FOR_WRITE
56
47
#endif
57
48
 
58
 
typedef struct st_typelib TYPELIB;
59
 
 
60
49
const uint32_t max_field_size= (uint32_t) 4294967295U;
61
50
 
62
51
class SendField;
63
52
class CreateField;
64
53
class TableShare;
65
54
class Field;
66
 
struct CacheField;
 
55
struct st_cache_field;
67
56
 
68
57
int field_conv(Field *to,Field *from);
69
58
 
 
59
inline uint32_t get_enum_pack_length(int elements)
 
60
{
 
61
  return elements < 256 ? 1 : 2;
 
62
}
 
63
 
70
64
/**
71
65
 * Class representing a Field in a Table
72
66
 *
73
67
 * @details
74
68
 *
75
 
 * The value stored in the Field object is stored in the
 
69
 * The value stored in the Field object is stored in the 
76
70
 * unsigned char pointer member variable called ptr.  The
77
 
 * val_xxx() methods retrieve this raw byte value and
 
71
 * val_xxx() methods retrieve this raw byte value and 
78
72
 * convert the byte into the appropriate output (int, decimal, etc).
79
73
 *
80
74
 * The store_xxx() methods take various input and convert
81
75
 * the input into the raw bytes stored in the ptr member variable.
82
76
 */
83
 
class DRIZZLED_API Field
 
77
class Field
84
78
{
85
79
  /* Prevent use of these */
86
 
  Field(const Field&);
 
80
  Field(const Field&); 
87
81
  void operator=(Field &);
88
 
 
89
82
public:
90
83
  unsigned char *ptr; /**< Position to field in record. Stores raw field value */
91
84
  unsigned char *null_ptr; /**< Byte where null_bit is */
92
85
 
93
86
  /**
94
 
   * Pointer to the Table object containing this Field
 
87
   * Pointer to the Table object containing this Field 
95
88
   *
96
89
   * @note You can use table->in_use as replacement for current_session member
97
90
   * only inside of val_*() and store() members (e.g. you can't use it in cons)
98
91
   */
99
 
private:
100
 
  Table *table;
101
 
 
102
 
public:
103
 
  Table *getTable()
104
 
  {
105
 
    assert(table);
106
 
    return table;
107
 
  }
108
 
 
109
 
  Table *getTable() const
110
 
  {
111
 
    assert(table);
112
 
    return table;
113
 
  }
114
 
 
115
 
  void setTable(Table *table_arg)
116
 
  {
117
 
    table= table_arg;
118
 
  }
119
 
 
 
92
  Table *table; 
120
93
  Table *orig_table; /**< Pointer to the original Table. @TODO What is "the original table"? */
 
94
  const char **table_name; /**< Pointer to the name of the table. @TODO This is redundant with Table::table_name. */
121
95
  const char *field_name; /**< Name of the field */
122
96
  LEX_STRING comment; /**< A comment about the field */
123
97
 
128
102
  key_map part_of_sortkey;
129
103
 
130
104
  /*
131
 
    We use three additional unireg types for TIMESTAMP for hysterical
132
 
    raisins and limitations in the MySQL FRM file format.
133
 
 
134
 
    A good TODO is to clean this up as we can support just about
135
 
    anything in the table proto message now.
 
105
    We use three additional unireg types for TIMESTAMP to overcome limitation
 
106
    of current binary format of .frm file. We'd like to be able to support
 
107
    NOW() as default and on update value for such fields but unable to hold
 
108
    this info anywhere except unireg_check field. This issue will be resolved
 
109
    in more clean way with transition to new text based .frm format.
 
110
    See also comment for Field_timestamp::Field_timestamp().
136
111
  */
137
112
  enum utype
138
 
  {
 
113
  { 
139
114
    NONE,
140
115
    NEXT_NUMBER,
141
116
    TIMESTAMP_OLD_FIELD,
147
122
  utype unireg_check;
148
123
  uint32_t field_length; /**< Length of this field in bytes */
149
124
  uint32_t flags;
150
 
 
151
 
  bool isUnsigned() const
152
 
  {
153
 
    return flags & UNSIGNED_FLAG;
154
 
  }
155
 
 
156
 
private:
157
125
  uint16_t field_index; /**< Index of this Field in Table::fields array */
158
 
 
159
 
public:
160
 
 
161
 
  uint16_t position() const
162
 
  {
163
 
    return field_index;
164
 
  }
165
 
 
166
 
  void setPosition(uint32_t arg)
167
 
  {
168
 
    field_index= arg;
169
 
  }
170
 
 
171
126
  unsigned char null_bit; /**< Bit used to test null bit */
172
127
  /**
173
128
     If true, this field was created in create_tmp_field_from_item from a NULL
179
134
   */
180
135
  bool is_created_from_null_item;
181
136
 
182
 
  static void *operator new(size_t size);
183
 
  static void *operator new(size_t size, memory::Root *mem_root);
 
137
  static void *operator new(size_t size) {return sql_alloc(size); }
 
138
  static void *operator new(size_t size, MEM_ROOT *mem_root)
 
139
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
184
140
  static void operator delete(void *, size_t)
185
 
  { }
186
 
  static void operator delete(void *, memory::Root *)
187
 
  { }
 
141
  { TRASH(ptr_arg, size); }
188
142
 
189
143
  Field(unsigned char *ptr_arg,
190
144
        uint32_t length_arg,
193
147
        utype unireg_check_arg,
194
148
        const char *field_name_arg);
195
149
  virtual ~Field() {}
196
 
 
197
 
  bool hasDefault() const
198
 
  {
199
 
    return not (flags & NO_DEFAULT_VALUE_FLAG);
200
 
  }
201
 
 
202
150
  /* Store functions returns 1 on overflow and -1 on fatal error */
203
 
  virtual int store(const char *to,
204
 
                    uint32_t length,
 
151
  virtual int store(const char *to, 
 
152
                    uint32_t length, 
205
153
                    const CHARSET_INFO * const cs)=0;
206
154
  virtual int store(double nr)=0;
207
155
  virtual int store(int64_t nr, bool unsigned_val)=0;
208
 
  virtual int store_decimal(const type::Decimal *d)=0;
209
 
  int store_and_check(enum_check_fields check_level,
210
 
                      const char *to,
211
 
                      uint32_t length,
212
 
                      const CHARSET_INFO * const cs);
 
156
  virtual int store_decimal(const my_decimal *d)=0;
 
157
  int store(const char *to, 
 
158
            uint32_t length,
 
159
            const CHARSET_INFO * const cs,
 
160
            enum_check_fields check_level);
213
161
  /**
214
162
    This is called when storing a date in a string.
215
163
 
216
164
    @note
217
165
      Needs to be changed if/when we want to support different time formats.
218
166
  */
219
 
  virtual int store_time(type::Time &ltime, type::timestamp_t t_type);
220
 
  virtual double val_real()=0;
221
 
  virtual int64_t val_int()=0;
222
 
  virtual type::Decimal *val_decimal(type::Decimal *);
223
 
  String *val_str_internal(String *str)
 
167
  virtual int store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type t_type);
 
168
  virtual double val_real(void)=0;
 
169
  virtual int64_t val_int(void)=0;
 
170
  virtual my_decimal *val_decimal(my_decimal *);
 
171
  inline String *val_str(String *str) 
224
172
  {
225
173
    return val_str(str, str);
226
174
  }
227
 
 
228
175
  /*
229
176
     val_str(buf1, buf2) gets two buffers and should use them as follows:
230
177
     if it needs a temp buffer to convert result to string - use buf1
238
185
     This trickery is used to decrease a number of malloc calls.
239
186
  */
240
187
  virtual String *val_str(String*, String *)=0;
241
 
 
 
188
  /**
 
189
   * Interpret field value as an integer but return the result as a string.
 
190
   *
 
191
   * This is used for printing bit_fields as numbers while debugging.
 
192
   */
 
193
  String *val_int_as_str(String *val_buffer, bool unsigned_flag);
242
194
  /*
243
195
   str_needs_quotes() returns true if the value returned by val_str() needs
244
196
   to be quoted when used in constructing an SQL query.
247
199
  virtual Item_result result_type () const=0;
248
200
  virtual Item_result cmp_type () const { return result_type(); }
249
201
  virtual Item_result cast_to_int_type () const { return result_type(); }
250
 
 
251
202
  /**
252
203
     Check whether a field type can be partially indexed by a key.
253
204
 
254
205
     This is a static method, rather than a virtual function, because we need
255
 
     to check the type of a non-Field in alter_table().
 
206
     to check the type of a non-Field in drizzled::alter_table().
256
207
 
257
208
     @param type  field type
258
209
 
294
245
   */
295
246
  virtual bool eq_def(Field *field);
296
247
 
297
 
  virtual bool is_timestamp() const
298
 
  {
299
 
    return false;
300
 
  }
301
 
 
302
248
  /**
303
249
   * Returns size (in bytes) used to store field data in memory
304
250
   * (i.e. it returns the maximum size of the field in a row of the table,
312
258
   * table, which is located on disk).
313
259
   */
314
260
  virtual uint32_t pack_length_in_rec() const;
315
 
 
316
 
  /**
317
 
   * Return the "real size" of the data in memory.
 
261
  /**
 
262
    Check to see if field size is compatible with destination.
 
263
 
 
264
    This method is used in row-based replication to verify that the slave's
 
265
    field size is less than or equal to the master's field size. The
 
266
    encoded field metadata (from the master or source) is decoded and compared
 
267
    to the size of this field (the slave or destination).
 
268
 
 
269
    @param   field_metadata   Encoded size in field metadata
 
270
 
 
271
    @retval 0 if this field's size is < the source field's size
 
272
    @retval 1 if this field's size is >= the source field's size
 
273
  */
 
274
  virtual int compatible_field_size(uint32_t field_metadata);
 
275
  virtual uint32_t pack_length_from_metadata(uint32_t field_metadata);
 
276
 
 
277
  /*
 
278
    This method is used to return the size of the data in a row-based
 
279
    replication row record. The default implementation of returning 0 is
 
280
    designed to allow fields that do not use metadata to return true (1)
 
281
    from compatible_field_size() which uses this function in the comparison.
 
282
    The default value for field metadata for fields that do not have
 
283
    metadata is 0. Thus, 0 == 0 means the fields are compatible in size.
 
284
 
 
285
    Note: While most classes that override this method return pack_length(),
 
286
    the classes Field_varstring, and Field_blob return
 
287
    field_length + 1, field_length, and pack_length_no_ptr() respectfully.
 
288
  */
 
289
  virtual uint32_t row_pack_length();
 
290
 
 
291
  /**
 
292
   * Return the "real size" of the data in memory. 
318
293
   * For varstrings, this does _not_ include the length bytes.
319
294
   */
320
295
  virtual uint32_t data_length();
342
317
  virtual uint32_t key_length() const;
343
318
  virtual enum_field_types type() const =0;
344
319
  virtual enum_field_types real_type() const;
345
 
  virtual int cmp_max(const unsigned char *a, const unsigned char *b, uint32_t max_len);
 
320
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
 
321
  virtual int cmp_max(const unsigned char *a, const unsigned char *b,
 
322
                      uint32_t max_len);
346
323
  virtual int cmp(const unsigned char *,const unsigned char *)=0;
347
 
  int cmp_internal(const unsigned char *str) { return cmp(ptr,str); }
348
324
  virtual int cmp_binary(const unsigned char *a,const unsigned char *b,
349
325
                         uint32_t max_length=UINT32_MAX);
350
326
  virtual int cmp_offset(uint32_t row_offset);
382
358
   * use field->val_int() for comparison.  Used to optimize clauses like
383
359
   * 'a_column BETWEEN date_const AND date_const'.
384
360
   */
385
 
  virtual bool can_be_compared_as_int64_t() const
 
361
  virtual bool can_be_compared_as_int64_t() const 
386
362
  {
387
363
    return false;
388
364
  }
389
365
  virtual void free() {}
390
 
  virtual Field *new_field(memory::Root *root,
 
366
  virtual Field *new_field(MEM_ROOT *root, 
391
367
                           Table *new_table,
392
368
                           bool keep_type);
393
 
  virtual Field *new_key_field(memory::Root *root, Table *new_table,
394
 
                               unsigned char *new_ptr,
 
369
  virtual Field *new_key_field(MEM_ROOT *root, Table *new_table,
 
370
                               unsigned char *new_ptr, 
395
371
                               unsigned char *new_null_ptr,
396
372
                               uint32_t new_null_bit);
397
373
  /** This is used to generate a field in Table from TableShare */
398
 
  Field *clone(memory::Root *mem_root, Table *new_table);
399
 
  void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
 
374
  Field *clone(MEM_ROOT *mem_root, Table *new_table);
 
375
  inline void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
400
376
  {
401
377
    ptr= ptr_arg;
402
378
    null_ptr= null_ptr_arg;
403
379
    null_bit= null_bit_arg;
404
380
  }
405
 
  void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
 
381
  inline void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
406
382
  virtual void move_field_offset(ptrdiff_t ptr_diff)
407
383
  {
408
384
    ptr= ADD_TO_PTR(ptr,ptr_diff, unsigned char*);
442
418
   * characters have maximal possible size (mbmaxlen). In the other words,
443
419
   * "length" parameter is a number of characters multiplied by
444
420
   * field_charset->mbmaxlen.
445
 
   *
 
421
   * 
446
422
   * @retval
447
423
   *   Number of copied bytes (excluding padded zero bytes -- see above).
448
424
   */
460
436
  {
461
437
    set_image(buff,length, &my_charset_bin);
462
438
  }
463
 
  int64_t val_int_offset(uint32_t row_offset)
 
439
  inline int64_t val_int_offset(uint32_t row_offset)
464
440
  {
465
441
    ptr+=row_offset;
466
442
    int64_t tmp=val_int();
468
444
    return tmp;
469
445
  }
470
446
 
471
 
  int64_t val_int_internal(const unsigned char *new_ptr)
 
447
  inline int64_t val_int(const unsigned char *new_ptr)
472
448
  {
473
449
    unsigned char *old_ptr= ptr;
474
450
    int64_t return_value;
475
 
    ptr= const_cast<unsigned char*>(new_ptr);
 
451
    ptr= (unsigned char*) new_ptr;
476
452
    return_value= val_int();
477
453
    ptr= old_ptr;
478
454
    return return_value;
479
455
  }
480
 
 
481
 
  String *val_str_internal(String *str, const unsigned char *new_ptr)
 
456
  inline String *val_str(String *str, const unsigned char *new_ptr)
482
457
  {
483
458
    unsigned char *old_ptr= ptr;
484
 
    ptr= const_cast<unsigned char*>(new_ptr);
485
 
    val_str_internal(str);
 
459
    ptr= (unsigned char*) new_ptr;
 
460
    val_str(str);
486
461
    ptr= old_ptr;
487
462
    return str;
488
463
  }
574
549
 
575
550
  virtual unsigned char *pack_key(unsigned char* to,
576
551
                                  const unsigned char *from,
577
 
                                  uint32_t max_length,
 
552
                                  uint32_t max_length, 
578
553
                                  bool low_byte_first)
579
554
  {
580
555
    return pack(to, from, max_length, low_byte_first);
591
566
    return max_length;
592
567
  }
593
568
 
594
 
  uint32_t offset(const unsigned char *record)
 
569
  inline uint32_t offset(unsigned char *record)
595
570
  {
596
571
    return (uint32_t) (ptr - record);
597
572
  }
598
573
  void copy_from_tmp(int offset);
599
 
  uint32_t fill_cache_field(CacheField *copy);
600
 
  virtual bool get_date(type::Time &ltime,uint32_t fuzzydate);
601
 
  virtual bool get_time(type::Time &ltime);
 
574
  uint32_t fill_cache_field(struct st_cache_field *copy);
 
575
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
576
  virtual bool get_time(DRIZZLE_TIME *ltime);
602
577
  virtual const CHARSET_INFO *charset(void) const { return &my_charset_bin; }
603
578
  virtual const CHARSET_INFO *sort_charset(void) const { return charset(); }
604
579
  virtual bool has_charset(void) const { return false; }
629
604
    @retval
630
605
      0 otherwise
631
606
  */
632
 
  bool set_warning(DRIZZLE_ERROR::enum_warning_level,
633
 
                   drizzled::error_t code,
 
607
  bool set_warning(DRIZZLE_ERROR::enum_warning_level, 
 
608
                   unsigned int code,
634
609
                   int cuted_increment);
635
610
  /**
636
611
    Produce warning or note about datetime string data saved into field.
647
622
      fields counter if count_cuted_fields ==FIELD_CHECK_IGNORE for current
648
623
      thread.
649
624
  */
650
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
651
 
                            drizzled::error_t code,
652
 
                            const char *str,
 
625
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
626
                            uint32_t code,
 
627
                            const char *str, 
653
628
                            uint32_t str_len,
654
 
                            type::timestamp_t ts_type,
 
629
                            enum enum_drizzle_timestamp_type ts_type, 
655
630
                            int cuted_increment);
656
631
  /**
657
632
    Produce warning or note about integer datetime value saved into field.
667
642
      fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
668
643
      thread.
669
644
  */
670
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
671
 
                            drizzled::error_t code,
672
 
                            int64_t nr,
673
 
                            type::timestamp_t ts_type,
 
645
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
646
                            uint32_t code,
 
647
                            int64_t nr, 
 
648
                            enum enum_drizzle_timestamp_type ts_type,
674
649
                            int cuted_increment);
675
650
  /**
676
651
    Produce warning or note about double datetime data saved into field.
685
660
      fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
686
661
      thread.
687
662
  */
688
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
689
 
                            const drizzled::error_t code,
690
 
                            double nr,
691
 
                            type::timestamp_t ts_type);
692
 
  bool check_overflow(int op_result)
 
663
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
664
                            const uint32_t code,
 
665
                            double nr, 
 
666
                            enum enum_drizzle_timestamp_type ts_type);
 
667
  inline bool check_overflow(int op_result)
693
668
  {
694
669
    return (op_result == E_DEC_OVERFLOW);
695
670
  }
723
698
    @return
724
699
      value converted from val
725
700
  */
726
 
  int64_t convert_decimal2int64_t(const type::Decimal *val,
 
701
  int64_t convert_decimal2int64_t(const my_decimal *val, 
727
702
                                  bool unsigned_flag,
728
703
                                  int *err);
729
704
  /* The max. number of characters */
730
 
  uint32_t char_length() const
 
705
  inline uint32_t char_length() const
731
706
  {
732
707
    return field_length / charset()->mbmaxlen;
733
708
  }
734
709
 
735
 
  enum column_format_type column_format() const
 
710
  inline enum column_format_type column_format() const
736
711
  {
737
712
    return (enum column_format_type)
738
713
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
759
734
  bool isWriteSet();
760
735
  void setReadSet(bool arg= true);
761
736
  void setWriteSet(bool arg= true);
762
 
 
763
 
protected:
764
 
 
765
 
  void pack_num(uint64_t arg, unsigned char *destination= NULL);
766
 
  void pack_num(uint32_t arg, unsigned char *destination= NULL);
767
 
  uint64_t unpack_num(uint64_t &destination, const unsigned char *arg= NULL) const;
768
 
  uint32_t unpack_num(uint32_t &destination, const unsigned char *arg= NULL) const;
769
737
};
770
738
 
771
 
std::ostream& operator<<(std::ostream& output, const Field &field);
772
 
 
773
 
} /* namespace drizzled */
774
 
 
775
 
/** @TODO Why is this in the middle of the file???*/
776
739
#include "drizzled/create_field.h"
777
740
 
778
 
namespace drizzled
779
 
{
780
 
 
781
741
/**
782
742
 * A class for sending field information to a client.
783
743
 *
786
746
 * Send_field is basically a stripped-down POD class for
787
747
 * representing basic information about a field...
788
748
 */
789
 
class SendField
 
749
class SendField 
790
750
{
791
751
public:
792
752
  const char *db_name;
802
762
  SendField() {}
803
763
};
804
764
 
 
765
/**
 
766
 * A class for quick copying data to fields
 
767
 */
 
768
class CopyField :public Sql_alloc
 
769
{
 
770
  /**
 
771
    Convenience definition of a copy function returned by
 
772
    get_copy_func.
 
773
  */
 
774
  typedef void Copy_func(CopyField*);
 
775
  Copy_func *get_copy_func(Field *to, Field *from);
 
776
public:
 
777
  unsigned char *from_ptr;
 
778
  unsigned char *to_ptr;
 
779
  unsigned char *from_null_ptr;
 
780
  unsigned char *to_null_ptr;
 
781
  bool *null_row;
 
782
  uint32_t from_bit;
 
783
  uint32_t to_bit;
 
784
  uint32_t from_length;
 
785
  uint32_t to_length;
 
786
  Field *from_field;
 
787
  Field *to_field;
 
788
  String tmp;                                   // For items
 
789
 
 
790
  CopyField() {}
 
791
  ~CopyField() {}
 
792
  void set(Field *to,Field *from,bool save);    // Field to field
 
793
  void set(unsigned char *to,Field *from);              // Field to string
 
794
  void (*do_copy)(CopyField *);
 
795
  void (*do_copy2)(CopyField *);                // Used to handle null values
 
796
};
 
797
 
 
798
Field *make_field(TableShare *share,
 
799
                  MEM_ROOT *root,
 
800
                  unsigned char *ptr,
 
801
                  uint32_t field_length,
 
802
                  bool is_nullable,
 
803
                  unsigned char *null_pos,
 
804
                  unsigned char null_bit,
 
805
                  uint8_t decimals,
 
806
                  enum_field_types field_type,
 
807
                  const CHARSET_INFO * cs,
 
808
                  Field::utype unireg_check,
 
809
                  TYPELIB *interval,
 
810
                  const char *field_name);
 
811
 
805
812
uint32_t pack_length_to_packflag(uint32_t type);
806
813
uint32_t calc_pack_length(enum_field_types type,uint32_t length);
807
814
int set_field_to_null(Field *field);
824
831
                            const char *str,
825
832
                            const char *strend);
826
833
 
827
 
} /* namespace drizzled */
828
 
 
829
834
#endif /* DRIZZLED_FIELD_H */