~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä
  • Date: 2010-12-20 03:21:44 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101220032144-7aqh2z403u7d7bdp
Merge Revision revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0 from MySQL InnoDB

Original revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0

Original Authors: Marko Mäkelä <marko.makela@oracle.com>
Original commit message:
row_ins_index_entry(): Note that only CREATE INDEX sets foreign=FALSE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLE_SERVER_FIELD_ENUM
22
 
#define DRIZZLE_SERVER_FIELD_ENUM
23
 
 
24
 
#include <drizzled/field/str.h>
25
 
 
26
 
class Field_enum :public Field_str {
27
 
protected:
28
 
  uint32_t packlength;
 
21
#ifndef DRIZZLED_FIELD_ENUM_H
 
22
#define DRIZZLED_FIELD_ENUM_H
 
23
 
 
24
#include "drizzled/field/str.h"
 
25
 
 
26
namespace drizzled
 
27
{
 
28
 
 
29
class Field_enum :public Field_str
 
30
{
29
31
public:
 
32
 
 
33
  using Field::store;
 
34
  using Field::val_int;
 
35
  using Field::val_str;
 
36
  using Field::cmp;
 
37
 
 
38
  static const int max_supported_elements = 0x10000;
 
39
 
 
40
  /** Internal storage for the string values of the ENUM */
30
41
  TYPELIB *typelib;
31
 
  Field_enum(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
 
42
  Field_enum(unsigned char *ptr_arg,
 
43
             uint32_t len_arg,
 
44
             unsigned char *null_ptr_arg,
32
45
             unsigned char null_bit_arg,
33
 
             enum utype unireg_check_arg, const char *field_name_arg,
34
 
             uint32_t packlength_arg,
 
46
             const char *field_name_arg,
35
47
             TYPELIB *typelib_arg,
36
48
             const CHARSET_INFO * const charset_arg)
37
 
    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
38
 
               unireg_check_arg, field_name_arg, charset_arg),
39
 
    packlength(packlength_arg),typelib(typelib_arg)
 
49
    :Field_str(ptr_arg,
 
50
               len_arg,
 
51
               null_ptr_arg,
 
52
               null_bit_arg,
 
53
                     field_name_arg,
 
54
               charset_arg),
 
55
    typelib(typelib_arg)
40
56
  {
41
 
      flags|=ENUM_FLAG;
 
57
    flags|= ENUM_FLAG;
42
58
  }
43
 
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
44
 
  enum_field_types type() const { return DRIZZLE_TYPE_ENUM; }
45
 
  enum Item_result cmp_type () const { return INT_RESULT; }
46
 
  enum Item_result cast_to_int_type () const { return INT_RESULT; }
47
 
  enum ha_base_keytype key_type() const;
48
 
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
 
59
  Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
 
60
  enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
 
61
  int  store(const char *to, uint32_t length, const CHARSET_INFO * const);
49
62
  int  store(double nr);
50
63
  int  store(int64_t nr, bool unsigned_val);
51
64
  double val_real(void);
52
65
  int64_t val_int(void);
53
 
  String *val_str(String*,String *);
54
 
  int cmp(const unsigned char *,const unsigned char *);
55
 
  void sort_string(unsigned char *buff,uint32_t length);
56
 
  uint32_t pack_length() const { return (uint32_t) packlength; }
 
66
  String *val_str(String*, String *);
 
67
  int cmp(const unsigned char *, const unsigned char *);
 
68
  void sort_string(unsigned char *buff, uint32_t length);
57
69
  void store_type(uint64_t value);
58
70
  void sql_type(String &str) const;
59
 
  uint32_t size_of() const { return sizeof(*this); }
60
 
  enum_field_types real_type() const { return DRIZZLE_TYPE_ENUM; }
61
 
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
62
 
  { return (field_metadata & 0x00ff); }
63
 
  uint32_t row_pack_length() { return pack_length(); }
64
 
  virtual bool zero_pack() const { return 0; }
65
 
  bool optimize_range(uint32_t idx __attribute__((unused)),
66
 
                      uint32_t part __attribute__((unused)))
67
 
  { return 0; }
68
71
  bool eq_def(Field *field);
69
 
  bool has_charset(void) const { return true; }
 
72
  enum_field_types type() const
 
73
  {
 
74
    return DRIZZLE_TYPE_ENUM;
 
75
  }
 
76
  enum Item_result cmp_type () const
 
77
  {
 
78
    return INT_RESULT;
 
79
  }
 
80
  enum Item_result cast_to_int_type () const
 
81
  {
 
82
    return INT_RESULT;
 
83
  }
 
84
  uint32_t pack_length() const { return 4; }
 
85
  uint32_t size_of() const
 
86
  {
 
87
    return sizeof(*this);
 
88
  }
 
89
  enum_field_types real_type() const
 
90
  {
 
91
    return DRIZZLE_TYPE_ENUM;
 
92
  }
 
93
  virtual bool zero_pack() const
 
94
  {
 
95
    return false;
 
96
  }
 
97
  bool optimize_range(uint32_t, uint32_t)
 
98
  {
 
99
    return false;
 
100
  }
 
101
  bool has_charset(void) const
 
102
  {
 
103
    return true;
 
104
  }
70
105
  /* enum and set are sorted as integers */
71
106
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
72
 
private:
73
 
  int do_save_field_metadata(unsigned char *first_byte);
74
107
};
75
108
 
76
 
#endif
 
109
} /* namespace drizzled */
 
110
 
 
111
#endif /* DRIZZLED_FIELD_ENUM_H */