~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

Merged from Toru - removal of my_time_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <drizzled/my_decimal.h>
30
30
#include <drizzled/sql_bitmap.h>
31
31
#include <drizzled/sql_list.h>
32
 
/* System-wide common data structures */
33
 
#include <drizzled/structs.h>
34
32
#include <string>
35
33
 
36
34
#define DATETIME_DEC                     6
44
42
class Create_field;
45
43
class virtual_column_info;
46
44
 
47
 
class TABLE_SHARE;
48
 
 
49
 
class Field;
 
45
typedef struct st_table_share TABLE_SHARE;
50
46
 
51
47
struct st_cache_field;
52
48
int field_conv(Field *to,Field *from);
56
52
  return elements < 256 ? 1 : 2;
57
53
}
58
54
 
 
55
inline uint32_t get_set_pack_length(int elements)
 
56
{
 
57
  uint32_t len= (elements + 7) / 8;
 
58
  return len > 4 ? 8 : len;
 
59
}
 
60
 
59
61
class Field
60
62
{
61
63
  Field(const Item &);                          /* Prevent use of these */
62
64
  void operator=(Field &);
63
65
public:
64
66
  static void *operator new(size_t size) {return sql_alloc(size); }
65
 
  static void *operator new(size_t size, MEM_ROOT *mem_root)
66
 
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
67
 
 
68
67
  static void operator delete(void *, size_t)
69
68
  { TRASH(ptr_arg, size); }
70
69
 
89
88
    in more clean way with transition to new text based .frm format.
90
89
    See also comment for Field_timestamp::Field_timestamp().
91
90
  */
92
 
  enum utype  { NONE,
93
 
                NEXT_NUMBER,
94
 
                TIMESTAMP_OLD_FIELD,
 
91
  enum utype  { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
 
92
                CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
 
93
                BIT_FIELD, TIMESTAMP_OLD_FIELD, CAPITALIZE, BLOB_FIELD,
95
94
                TIMESTAMP_DN_FIELD, TIMESTAMP_UN_FIELD, TIMESTAMP_DNUN_FIELD};
96
95
  enum imagetype { itRAW, itMBR};
97
96
 
125
124
        const char *field_name_arg);
126
125
  virtual ~Field() {}
127
126
  /* Store functions returns 1 on overflow and -1 on fatal error */
128
 
  virtual int store(const char *to, uint32_t length,
129
 
                    const CHARSET_INFO * const cs)=0;
130
 
  virtual int store(double nr)=0;
131
 
  virtual int store(int64_t nr, bool unsigned_val)=0;
132
 
  virtual int store_decimal(const my_decimal *d)=0;
133
 
  int store(const char *to, uint32_t length,
134
 
            const CHARSET_INFO * const cs,
135
 
            enum_check_fields check_level);
 
127
  virtual int  store(const char *to, uint32_t length,
 
128
                     const CHARSET_INFO * const cs)=0;
 
129
  virtual int  store(double nr)=0;
 
130
  virtual int  store(int64_t nr, bool unsigned_val)=0;
 
131
  virtual int  store_decimal(const my_decimal *d)=0;
136
132
  virtual int store_time(DRIZZLE_TIME *ltime,
137
133
                         enum enum_drizzle_timestamp_type t_type);
 
134
  int store(const char *to, uint32_t length, const CHARSET_INFO * const cs,
 
135
            enum_check_fields check_level);
138
136
  virtual double val_real(void)=0;
139
137
  virtual int64_t val_int(void)=0;
140
138
  virtual my_decimal *val_decimal(my_decimal *);
381
379
    return length;
382
380
  }
383
381
  virtual void set_key_image(const unsigned char *buff,uint32_t length)
384
 
  { set_image(buff,length, &my_charset_bin); }
 
382
    { set_image(buff,length, &my_charset_bin); }
385
383
  inline int64_t val_int_offset(uint32_t row_offset)
386
 
  {
387
 
    ptr+=row_offset;
388
 
    int64_t tmp=val_int();
389
 
    ptr-=row_offset;
390
 
    return tmp;
391
 
  }
392
 
 
 
384
    {
 
385
      ptr+=row_offset;
 
386
      int64_t tmp=val_int();
 
387
      ptr-=row_offset;
 
388
      return tmp;
 
389
    }
393
390
  inline int64_t val_int(const unsigned char *new_ptr)
394
391
  {
395
392
    unsigned char *old_ptr= ptr;
407
404
    ptr= old_ptr;
408
405
    return str;
409
406
  }
410
 
 
411
 
  virtual unsigned char *pack(unsigned char *to,
412
 
                              const unsigned char *from,
413
 
                              uint32_t max_length,
414
 
                              bool low_byte_first);
415
 
 
 
407
  virtual bool send_binary(Protocol *protocol);
 
408
 
 
409
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
 
410
                              uint32_t max_length, bool low_byte_first);
 
411
  /**
 
412
     @overload Field::pack(unsigned char*, const unsigned char*,
 
413
                           uint32_t, bool)
 
414
  */
416
415
  unsigned char *pack(unsigned char *to, const unsigned char *from);
417
416
 
418
417
  virtual const unsigned char *unpack(unsigned char* to,
423
422
     @overload Field::unpack(unsigned char*, const unsigned char*,
424
423
                             uint32_t, bool)
425
424
  */
426
 
  const unsigned char *unpack(unsigned char* to,
427
 
                              const unsigned char *from);
 
425
  const unsigned char *unpack(unsigned char* to, const unsigned char *from);
428
426
 
429
427
  virtual unsigned char *pack_key(unsigned char* to, const unsigned char *from,
430
428
                          uint32_t max_length, bool low_byte_first)
587
585
  const CHARSET_INFO *charset;
588
586
  Field *field;                         // For alter table
589
587
 
590
 
  uint8_t       interval_id;    // For rea_create_table
 
588
  uint8_t row,col,sc_length,interval_id;        // For rea_create_table
591
589
  uint32_t      offset,pack_flag;
592
590
 
593
591
  /* Virtual column expression statement */
672
670
};
673
671
 
674
672
 
675
 
Field *make_field(TABLE_SHARE *share, MEM_ROOT *root, unsigned char *ptr, uint32_t field_length,
 
673
Field *make_field(TABLE_SHARE *share, unsigned char *ptr, uint32_t field_length,
676
674
                  unsigned char *null_pos, unsigned char null_bit,
677
675
                  uint32_t pack_flag, enum_field_types field_type,
678
676
                  const CHARSET_INFO * cs,