~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

Merge Trond

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 *
67
67
 * @details
68
68
 *
69
 
 * The value stored in the Field object is stored in the 
 
69
 * The value stored in the Field object is stored in the
70
70
 * unsigned char pointer member variable called ptr.  The
71
 
 * val_xxx() methods retrieve this raw byte value and 
 
71
 * val_xxx() methods retrieve this raw byte value and
72
72
 * convert the byte into the appropriate output (int, decimal, etc).
73
73
 *
74
74
 * The store_xxx() methods take various input and convert
77
77
class Field
78
78
{
79
79
  /* Prevent use of these */
80
 
  Field(const Field&); 
 
80
  Field(const Field&);
81
81
  void operator=(Field &);
82
82
public:
83
83
  unsigned char *ptr; /**< Position to field in record. Stores raw field value */
84
84
  unsigned char *null_ptr; /**< Byte where null_bit is */
85
85
 
86
86
  /**
87
 
   * Pointer to the Table object containing this Field 
 
87
   * Pointer to the Table object containing this Field
88
88
   *
89
89
   * @note You can use table->in_use as replacement for current_session member
90
90
   * only inside of val_*() and store() members (e.g. you can't use it in cons)
91
91
   */
92
 
  Table *table; 
 
92
  Table *table;
93
93
  Table *orig_table; /**< Pointer to the original Table. @TODO What is "the original table"? */
94
94
  const char **table_name; /**< Pointer to the name of the table. @TODO This is redundant with Table::table_name. */
95
95
  const char *field_name; /**< Name of the field */
110
110
    See also comment for Field_timestamp::Field_timestamp().
111
111
  */
112
112
  enum utype
113
 
  { 
 
113
  {
114
114
    NONE,
115
115
    NEXT_NUMBER,
116
116
    TIMESTAMP_OLD_FIELD,
136
136
 
137
137
  static void *operator new(size_t size) {return sql_alloc(size); }
138
138
  static void *operator new(size_t size, MEM_ROOT *mem_root)
139
 
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
 
139
  { return alloc_root(mem_root, static_cast<uint32_t>(size)); }
140
140
  static void operator delete(void *, size_t)
141
141
  { TRASH(ptr_arg, size); }
142
142
 
148
148
        const char *field_name_arg);
149
149
  virtual ~Field() {}
150
150
  /* Store functions returns 1 on overflow and -1 on fatal error */
151
 
  virtual int store(const char *to, 
152
 
                    uint32_t length, 
 
151
  virtual int store(const char *to,
 
152
                    uint32_t length,
153
153
                    const CHARSET_INFO * const cs)=0;
154
154
  virtual int store(double nr)=0;
155
155
  virtual int store(int64_t nr, bool unsigned_val)=0;
156
156
  virtual int store_decimal(const my_decimal *d)=0;
157
 
  int store(const char *to, 
 
157
  int store(const char *to,
158
158
            uint32_t length,
159
159
            const CHARSET_INFO * const cs,
160
160
            enum_check_fields check_level);
168
168
  virtual double val_real(void)=0;
169
169
  virtual int64_t val_int(void)=0;
170
170
  virtual my_decimal *val_decimal(my_decimal *);
171
 
  inline String *val_str(String *str) 
 
171
  inline String *val_str(String *str)
172
172
  {
173
173
    return val_str(str, str);
174
174
  }
289
289
  virtual uint32_t row_pack_length();
290
290
 
291
291
  /**
292
 
   * Return the "real size" of the data in memory. 
 
292
   * Return the "real size" of the data in memory.
293
293
   * For varstrings, this does _not_ include the length bytes.
294
294
   */
295
295
  virtual uint32_t data_length();
358
358
   * use field->val_int() for comparison.  Used to optimize clauses like
359
359
   * 'a_column BETWEEN date_const AND date_const'.
360
360
   */
361
 
  virtual bool can_be_compared_as_int64_t() const 
 
361
  virtual bool can_be_compared_as_int64_t() const
362
362
  {
363
363
    return false;
364
364
  }
365
365
  virtual void free() {}
366
 
  virtual Field *new_field(MEM_ROOT *root, 
 
366
  virtual Field *new_field(MEM_ROOT *root,
367
367
                           Table *new_table,
368
368
                           bool keep_type);
369
369
  virtual Field *new_key_field(MEM_ROOT *root, Table *new_table,
370
 
                               unsigned char *new_ptr, 
 
370
                               unsigned char *new_ptr,
371
371
                               unsigned char *new_null_ptr,
372
372
                               uint32_t new_null_bit);
373
373
  /** This is used to generate a field in Table from TableShare */
418
418
   * characters have maximal possible size (mbmaxlen). In the other words,
419
419
   * "length" parameter is a number of characters multiplied by
420
420
   * field_charset->mbmaxlen.
421
 
   * 
 
421
   *
422
422
   * @retval
423
423
   *   Number of copied bytes (excluding padded zero bytes -- see above).
424
424
   */
448
448
  {
449
449
    unsigned char *old_ptr= ptr;
450
450
    int64_t return_value;
451
 
    ptr= (unsigned char*) new_ptr;
 
451
    ptr= const_cast<unsigned char*>(new_ptr);
452
452
    return_value= val_int();
453
453
    ptr= old_ptr;
454
454
    return return_value;
456
456
  inline String *val_str(String *str, const unsigned char *new_ptr)
457
457
  {
458
458
    unsigned char *old_ptr= ptr;
459
 
    ptr= (unsigned char*) new_ptr;
 
459
    ptr= const_cast<unsigned char*>(new_ptr);
460
460
    val_str(str);
461
461
    ptr= old_ptr;
462
462
    return str;
549
549
 
550
550
  virtual unsigned char *pack_key(unsigned char* to,
551
551
                                  const unsigned char *from,
552
 
                                  uint32_t max_length, 
 
552
                                  uint32_t max_length,
553
553
                                  bool low_byte_first)
554
554
  {
555
555
    return pack(to, from, max_length, low_byte_first);
604
604
    @retval
605
605
      0 otherwise
606
606
  */
607
 
  bool set_warning(DRIZZLE_ERROR::enum_warning_level, 
 
607
  bool set_warning(DRIZZLE_ERROR::enum_warning_level,
608
608
                   unsigned int code,
609
609
                   int cuted_increment);
610
610
  /**
622
622
      fields counter if count_cuted_fields ==FIELD_CHECK_IGNORE for current
623
623
      thread.
624
624
  */
625
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
625
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
626
626
                            uint32_t code,
627
 
                            const char *str, 
 
627
                            const char *str,
628
628
                            uint32_t str_len,
629
 
                            enum enum_drizzle_timestamp_type ts_type, 
 
629
                            enum enum_drizzle_timestamp_type ts_type,
630
630
                            int cuted_increment);
631
631
  /**
632
632
    Produce warning or note about integer datetime value saved into field.
642
642
      fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
643
643
      thread.
644
644
  */
645
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
645
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
646
646
                            uint32_t code,
647
 
                            int64_t nr, 
 
647
                            int64_t nr,
648
648
                            enum enum_drizzle_timestamp_type ts_type,
649
649
                            int cuted_increment);
650
650
  /**
660
660
      fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current
661
661
      thread.
662
662
  */
663
 
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, 
 
663
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
664
664
                            const uint32_t code,
665
 
                            double nr, 
 
665
                            double nr,
666
666
                            enum enum_drizzle_timestamp_type ts_type);
667
667
  inline bool check_overflow(int op_result)
668
668
  {
698
698
    @return
699
699
      value converted from val
700
700
  */
701
 
  int64_t convert_decimal2int64_t(const my_decimal *val, 
 
701
  int64_t convert_decimal2int64_t(const my_decimal *val,
702
702
                                  bool unsigned_flag,
703
703
                                  int *err);
704
704
  /* The max. number of characters */
746
746
 * Send_field is basically a stripped-down POD class for
747
747
 * representing basic information about a field...
748
748
 */
749
 
class SendField 
 
749
class SendField
750
750
{
751
751
public:
752
752
  const char *db_name;