~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.h

  • Committer: Lee Bieber
  • Date: 2011-01-28 21:08:33 UTC
  • mfrom: (2119.4.3 try-visibility)
  • Revision ID: kalebral@gmail.com-20110128210833-nro17n81etdpcylm
Merge Monty - Enable -fvisibility=hidden

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#ifndef DRIZZLED_FIELD_H
28
28
#define DRIZZLED_FIELD_H
29
29
 
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>
35
 
#include <drizzled/charset_info.h>
36
 
#include <drizzled/item_result.h>
37
 
#include <drizzled/charset_info.h>
 
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"
 
35
#include "drizzled/charset_info.h"
 
36
#include "drizzled/item_result.h"
 
37
#include "drizzled/visibility.h"
38
38
 
39
39
#include <string>
40
40
#include <vector>
41
41
 
42
 
#include <drizzled/visibility.h>
 
42
#include "drizzled/visibility.h"
43
43
 
44
44
namespace drizzled
45
45
{
217
217
      Needs to be changed if/when we want to support different time formats.
218
218
  */
219
219
  virtual int store_time(type::Time &ltime, type::timestamp_t t_type);
220
 
  virtual double val_real() const=0;
221
 
  virtual int64_t val_int() const =0;
222
 
  virtual type::Decimal *val_decimal(type::Decimal *) const;
223
 
  String *val_str_internal(String *str) const
 
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)
224
224
  {
225
225
    return val_str(str, str);
226
226
  }
227
 
 
228
227
  /*
229
228
     val_str(buf1, buf2) gets two buffers and should use them as follows:
230
229
     if it needs a temp buffer to convert result to string - use buf1
237
236
     an unnecessary free (and later, may be an alloc).
238
237
     This trickery is used to decrease a number of malloc calls.
239
238
  */
240
 
  virtual String *val_str(String*, String *) const =0;
241
 
 
 
239
  virtual String *val_str(String*, String *)=0;
242
240
  /*
243
241
   str_needs_quotes() returns true if the value returned by val_str() needs
244
242
   to be quoted when used in constructing an SQL query.
363
361
  // For new field
364
362
  virtual uint32_t size_of() const =0;
365
363
 
366
 
  bool is_null(ptrdiff_t row_offset= 0) const;
367
 
  bool is_real_null(ptrdiff_t row_offset= 0) const;
368
 
  bool is_null_in_record(const unsigned char *record) const;
369
 
  bool is_null_in_record_with_offset(ptrdiff_t offset) const;
 
364
  bool is_null(ptrdiff_t row_offset= 0);
 
365
  bool is_real_null(ptrdiff_t row_offset= 0);
 
366
  bool is_null_in_record(const unsigned char *record);
 
367
  bool is_null_in_record_with_offset(ptrdiff_t offset);
370
368
  void set_null(ptrdiff_t row_offset= 0);
371
369
  void set_notnull(ptrdiff_t row_offset= 0);
372
 
  bool maybe_null(void) const;
373
 
  bool real_maybe_null(void) const;
 
370
  bool maybe_null(void);
 
371
  bool real_maybe_null(void);
374
372
 
375
373
  virtual void make_field(SendField *);
376
374
  virtual void sort_string(unsigned char *buff,uint32_t length)=0;
471
469
  int64_t val_int_internal(const unsigned char *new_ptr)
472
470
  {
473
471
    unsigned char *old_ptr= ptr;
 
472
    int64_t return_value;
474
473
    ptr= const_cast<unsigned char*>(new_ptr);
475
 
    int64_t return_value= val_int();
 
474
    return_value= val_int();
476
475
    ptr= old_ptr;
477
476
    return return_value;
478
477
  }
596
595
  }
597
596
  void copy_from_tmp(int offset);
598
597
  uint32_t fill_cache_field(CacheField *copy);
599
 
  virtual bool get_date(type::Time &ltime,uint32_t fuzzydate) const;
600
 
  virtual bool get_time(type::Time &ltime) const;
 
598
  virtual bool get_date(type::Time &ltime,uint32_t fuzzydate);
 
599
  virtual bool get_time(type::Time &ltime);
601
600
  virtual const CHARSET_INFO *charset(void) const { return &my_charset_bin; }
602
601
  virtual const CHARSET_INFO *sort_charset(void) const { return charset(); }
603
602
  virtual bool has_charset(void) const { return false; }
738
737
  }
739
738
 
740
739
  /* Hash value */
741
 
  virtual void hash(uint32_t *nr, uint32_t *nr2) const;
 
740
  virtual void hash(uint32_t *nr, uint32_t *nr2);
742
741
  friend bool reopen_table(Session *,Table *,bool);
743
742
 
744
743
  friend class CopyField;
754
753
  friend class Item_sum_max;
755
754
  friend class Item_func_group_concat;
756
755
 
757
 
  bool isReadSet() const;
 
756
  bool isReadSet();
758
757
  bool isWriteSet();
759
758
  void setReadSet(bool arg= true);
760
759
  void setWriteSet(bool arg= true);
767
766
  uint32_t unpack_num(uint32_t &destination, const unsigned char *arg= NULL) const;
768
767
};
769
768
 
770
 
namespace field {
771
 
 
772
 
inline bool isDateTime(const enum_field_types &arg)
773
 
{
774
 
  switch (arg)
775
 
  {
776
 
  case DRIZZLE_TYPE_DATE:
777
 
  case DRIZZLE_TYPE_DATETIME:
778
 
  case DRIZZLE_TYPE_MICROTIME:
779
 
  case DRIZZLE_TYPE_TIME:
780
 
  case DRIZZLE_TYPE_TIMESTAMP:
781
 
    return true;
782
 
 
783
 
  case DRIZZLE_TYPE_BLOB:
784
 
  case DRIZZLE_TYPE_BOOLEAN:
785
 
  case DRIZZLE_TYPE_DECIMAL:
786
 
  case DRIZZLE_TYPE_DOUBLE:
787
 
  case DRIZZLE_TYPE_ENUM:
788
 
  case DRIZZLE_TYPE_LONG:
789
 
  case DRIZZLE_TYPE_LONGLONG:
790
 
  case DRIZZLE_TYPE_NULL:
791
 
  case DRIZZLE_TYPE_UUID:
792
 
  case DRIZZLE_TYPE_VARCHAR:
793
 
    return false;
794
 
  }
795
 
 
796
 
  assert(0);
797
 
  abort();
798
 
}
799
 
 
800
 
} // namespace field
801
 
 
802
769
std::ostream& operator<<(std::ostream& output, const Field &field);
803
770
 
804
771
} /* namespace drizzled */
805
772
 
806
773
/** @TODO Why is this in the middle of the file???*/
807
 
#include <drizzled/create_field.h>
 
774
#include "drizzled/create_field.h"
808
775
 
809
776
namespace drizzled
810
777
{
833
800
  SendField() {}
834
801
};
835
802
 
 
803
/**
 
804
 * A class for quick copying data to fields
 
805
 */
 
806
class CopyField :public memory::SqlAlloc
 
807
{
 
808
  /**
 
809
    Convenience definition of a copy function returned by
 
810
    get_copy_func.
 
811
  */
 
812
  typedef void Copy_func(CopyField*);
 
813
  Copy_func *get_copy_func(Field *to, Field *from);
 
814
 
 
815
public:
 
816
  unsigned char *from_ptr;
 
817
  unsigned char *to_ptr;
 
818
  unsigned char *from_null_ptr;
 
819
  unsigned char *to_null_ptr;
 
820
  bool *null_row;
 
821
  uint32_t from_bit;
 
822
  uint32_t to_bit;
 
823
  uint32_t from_length;
 
824
  uint32_t to_length;
 
825
  Field *from_field;
 
826
  Field *to_field;
 
827
  String tmp;                                   // For items
 
828
 
 
829
  CopyField() :
 
830
    from_ptr(0),
 
831
    to_ptr(0),
 
832
    from_null_ptr(0),
 
833
    to_null_ptr(0),
 
834
    null_row(0),
 
835
    from_bit(0),
 
836
    to_bit(0),
 
837
    from_length(0),
 
838
    to_length(0),
 
839
    from_field(0),
 
840
    to_field(0)
 
841
  {}
 
842
 
 
843
  ~CopyField()
 
844
  {}
 
845
 
 
846
  void set(Field *to,Field *from,bool save);    // Field to field
 
847
  void set(unsigned char *to,Field *from);              // Field to string
 
848
  void (*do_copy)(CopyField *);
 
849
  void (*do_copy2)(CopyField *);                // Used to handle null values
 
850
};
 
851
 
836
852
uint32_t pack_length_to_packflag(uint32_t type);
837
853
uint32_t calc_pack_length(enum_field_types type,uint32_t length);
838
854
int set_field_to_null(Field *field);