~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

  • Committer: Brian Aker
  • Date: 2009-10-01 22:56:26 UTC
  • mto: (1154.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1155.
  • Revision ID: brian@gaz-20091001225626-sb1pdykpxlnkheaj
Remove Factory/make scheduler work like everything else.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 MySQL
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifndef DRIZZLED_FIELD_ENUM_H
 
22
#define DRIZZLED_FIELD_ENUM_H
 
23
 
 
24
#include "drizzled/field/str.h"
 
25
 
 
26
class Field_enum :public Field_str 
 
27
{
 
28
protected:
 
29
  uint32_t packlength;
 
30
public:
 
31
 
 
32
  using Field::store;
 
33
  using Field::val_int;
 
34
  using Field::val_str;
 
35
  using Field::cmp;
 
36
 
 
37
  /** Internal storage for the string values of the ENUM */
 
38
  TYPELIB *typelib;
 
39
  Field_enum(unsigned char *ptr_arg,
 
40
             uint32_t len_arg,
 
41
             unsigned char *null_ptr_arg,
 
42
             unsigned char null_bit_arg,
 
43
             const char *field_name_arg,
 
44
             uint32_t packlength_arg,
 
45
             TYPELIB *typelib_arg,
 
46
             const CHARSET_INFO * const charset_arg)
 
47
    :Field_str(ptr_arg,
 
48
               len_arg,
 
49
               null_ptr_arg,
 
50
               null_bit_arg,
 
51
                     field_name_arg,
 
52
               charset_arg),
 
53
    packlength(packlength_arg),
 
54
    typelib(typelib_arg)
 
55
  {
 
56
    flags|= ENUM_FLAG;
 
57
  }
 
58
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
 
59
  enum ha_base_keytype key_type() const;
 
60
  int  store(const char *to, uint32_t length, const CHARSET_INFO * const);
 
61
  int  store(double nr);
 
62
  int  store(int64_t nr, bool unsigned_val);
 
63
  double val_real(void);
 
64
  int64_t val_int(void);
 
65
  String *val_str(String*, String *);
 
66
  int cmp(const unsigned char *, const unsigned char *);
 
67
  void sort_string(unsigned char *buff, uint32_t length);
 
68
  void store_type(uint64_t value);
 
69
  void sql_type(String &str) const;
 
70
  bool eq_def(Field *field);
 
71
  enum_field_types type() const
 
72
  {
 
73
    return DRIZZLE_TYPE_ENUM;
 
74
  }
 
75
  enum Item_result cmp_type () const
 
76
  {
 
77
    return INT_RESULT;
 
78
  }
 
79
  enum Item_result cast_to_int_type () const
 
80
  {
 
81
    return INT_RESULT;
 
82
  }
 
83
  uint32_t pack_length() const
 
84
  {
 
85
    return (uint32_t) packlength;
 
86
  }
 
87
  uint32_t size_of() const
 
88
  {
 
89
    return sizeof(*this);
 
90
  }
 
91
  enum_field_types real_type() const
 
92
  {
 
93
    return DRIZZLE_TYPE_ENUM;
 
94
  }
 
95
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
 
96
  {
 
97
    return (field_metadata & 0x00ff);
 
98
  }
 
99
  uint32_t row_pack_length()
 
100
  { 
 
101
    return pack_length();
 
102
  }
 
103
  virtual bool zero_pack() const
 
104
  {
 
105
    return false;
 
106
  }
 
107
  bool optimize_range(uint32_t, uint32_t) 
 
108
  {
 
109
    return false;
 
110
  }
 
111
  bool has_charset(void) const
 
112
  {
 
113
    return true;
 
114
  }
 
115
  /* enum and set are sorted as integers */
 
116
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
 
117
private:
 
118
  int do_save_field_metadata(unsigned char *first_byte);
 
119
};
 
120
 
 
121
#endif /* DRIZZLED_FIELD_ENUM_H */