~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

  • Committer: Brian Aker
  • Date: 2010-12-18 10:14:05 UTC
  • mfrom: (2008.1.3 clean)
  • Revision ID: brian@tangent.org-20101218101405-qjbse29shi9coklg
Merge of user identifier work

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
  /* Prevent use of these */
81
81
  Field(const Field&);
82
82
  void operator=(Field &);
 
83
 
83
84
public:
84
85
  unsigned char *ptr; /**< Position to field in record. Stores raw field value */
85
86
  unsigned char *null_ptr; /**< Byte where null_bit is */
140
141
  utype unireg_check;
141
142
  uint32_t field_length; /**< Length of this field in bytes */
142
143
  uint32_t flags;
 
144
private:
143
145
  uint16_t field_index; /**< Index of this Field in Table::fields array */
 
146
 
 
147
public:
 
148
 
 
149
  uint16_t position() const
 
150
  {
 
151
    return field_index;
 
152
  }
 
153
 
 
154
  void setPosition(uint32_t arg)
 
155
  {
 
156
    field_index= arg;
 
157
  }
 
158
 
144
159
  unsigned char null_bit; /**< Bit used to test null bit */
145
160
  /**
146
161
     If true, this field was created in create_tmp_field_from_item from a NULL
166
181
        utype unireg_check_arg,
167
182
        const char *field_name_arg);
168
183
  virtual ~Field() {}
 
184
 
 
185
  bool hasDefault() const
 
186
  {
 
187
    return not (flags & NO_DEFAULT_VALUE_FLAG);
 
188
  }
 
189
 
169
190
  /* Store functions returns 1 on overflow and -1 on fatal error */
170
191
  virtual int store(const char *to,
171
192
                    uint32_t length,
173
194
  virtual int store(double nr)=0;
174
195
  virtual int store(int64_t nr, bool unsigned_val)=0;
175
196
  virtual int store_decimal(const my_decimal *d)=0;
176
 
  int store(const char *to,
177
 
            uint32_t length,
178
 
            const CHARSET_INFO * const cs,
179
 
            enum_check_fields check_level);
 
197
  int store_and_check(enum_check_fields check_level,
 
198
                      const char *to,
 
199
                      uint32_t length,
 
200
                      const CHARSET_INFO * const cs);
180
201
  /**
181
202
    This is called when storing a date in a string.
182
203
 
184
205
      Needs to be changed if/when we want to support different time formats.
185
206
  */
186
207
  virtual int store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type t_type);
187
 
  virtual double val_real(void)=0;
188
 
  virtual int64_t val_int(void)=0;
 
208
  virtual double val_real()=0;
 
209
  virtual int64_t val_int()=0;
189
210
  virtual my_decimal *val_decimal(my_decimal *);
190
 
  inline String *val_str(String *str)
 
211
  String *val_str_internal(String *str)
191
212
  {
192
213
    return val_str(str, str);
193
214
  }
301
322
  virtual uint32_t key_length() const;
302
323
  virtual enum_field_types type() const =0;
303
324
  virtual enum_field_types real_type() const;
304
 
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
305
 
  virtual int cmp_max(const unsigned char *a, const unsigned char *b,
306
 
                      uint32_t max_len);
 
325
  virtual int cmp_max(const unsigned char *a, const unsigned char *b, uint32_t max_len);
307
326
  virtual int cmp(const unsigned char *,const unsigned char *)=0;
 
327
  int cmp_internal(const unsigned char *str) { return cmp(ptr,str); }
308
328
  virtual int cmp_binary(const unsigned char *a,const unsigned char *b,
309
329
                         uint32_t max_length=UINT32_MAX);
310
330
  virtual int cmp_offset(uint32_t row_offset);
356
376
                               uint32_t new_null_bit);
357
377
  /** This is used to generate a field in Table from TableShare */
358
378
  Field *clone(memory::Root *mem_root, Table *new_table);
359
 
  inline void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
 
379
  void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
360
380
  {
361
381
    ptr= ptr_arg;
362
382
    null_ptr= null_ptr_arg;
363
383
    null_bit= null_bit_arg;
364
384
  }
365
 
  inline void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
 
385
  void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
366
386
  virtual void move_field_offset(ptrdiff_t ptr_diff)
367
387
  {
368
388
    ptr= ADD_TO_PTR(ptr,ptr_diff, unsigned char*);
420
440
  {
421
441
    set_image(buff,length, &my_charset_bin);
422
442
  }
423
 
  inline int64_t val_int_offset(uint32_t row_offset)
 
443
  int64_t val_int_offset(uint32_t row_offset)
424
444
  {
425
445
    ptr+=row_offset;
426
446
    int64_t tmp=val_int();
428
448
    return tmp;
429
449
  }
430
450
 
431
 
  inline int64_t val_int(const unsigned char *new_ptr)
 
451
  int64_t val_int_internal(const unsigned char *new_ptr)
432
452
  {
433
453
    unsigned char *old_ptr= ptr;
434
454
    int64_t return_value;
437
457
    ptr= old_ptr;
438
458
    return return_value;
439
459
  }
440
 
  inline String *val_str(String *str, const unsigned char *new_ptr)
 
460
 
 
461
  String *val_str_internal(String *str, const unsigned char *new_ptr)
441
462
  {
442
463
    unsigned char *old_ptr= ptr;
443
464
    ptr= const_cast<unsigned char*>(new_ptr);
444
 
    val_str(str);
 
465
    val_str_internal(str);
445
466
    ptr= old_ptr;
446
467
    return str;
447
468
  }
550
571
    return max_length;
551
572
  }
552
573
 
553
 
  inline uint32_t offset(const unsigned char *record)
 
574
  uint32_t offset(const unsigned char *record)
554
575
  {
555
576
    return (uint32_t) (ptr - record);
556
577
  }
648
669
                            const uint32_t code,
649
670
                            double nr,
650
671
                            enum enum_drizzle_timestamp_type ts_type);
651
 
  inline bool check_overflow(int op_result)
 
672
  bool check_overflow(int op_result)
652
673
  {
653
674
    return (op_result == E_DEC_OVERFLOW);
654
675
  }
686
707
                                  bool unsigned_flag,
687
708
                                  int *err);
688
709
  /* The max. number of characters */
689
 
  inline uint32_t char_length() const
 
710
  uint32_t char_length() const
690
711
  {
691
712
    return field_length / charset()->mbmaxlen;
692
713
  }
693
714
 
694
 
  inline enum column_format_type column_format() const
 
715
  enum column_format_type column_format() const
695
716
  {
696
717
    return (enum column_format_type)
697
718
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
720
741
  void setWriteSet(bool arg= true);
721
742
};
722
743
 
 
744
std::ostream& operator<<(std::ostream& output, const Field &field);
 
745
 
723
746
} /* namespace drizzled */
724
747
 
725
748
/** @TODO Why is this in the middle of the file???*/