~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

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
 
namespace drizzled
27
 
{
28
 
 
29
 
class Field_enum :public Field_str 
30
 
{
31
 
protected:
32
 
  uint32_t packlength;
33
 
public:
34
 
 
35
 
  using Field::store;
36
 
  using Field::val_int;
37
 
  using Field::val_str;
38
 
  using Field::cmp;
39
 
 
40
 
  /** Internal storage for the string values of the ENUM */
41
 
  TYPELIB *typelib;
42
 
  Field_enum(unsigned char *ptr_arg,
43
 
             uint32_t len_arg,
44
 
             unsigned char *null_ptr_arg,
45
 
             unsigned char null_bit_arg,
46
 
             const char *field_name_arg,
47
 
             uint32_t packlength_arg,
48
 
             TYPELIB *typelib_arg,
49
 
             const CHARSET_INFO * const charset_arg)
50
 
    :Field_str(ptr_arg,
51
 
               len_arg,
52
 
               null_ptr_arg,
53
 
               null_bit_arg,
54
 
                     field_name_arg,
55
 
               charset_arg),
56
 
    packlength(packlength_arg),
57
 
    typelib(typelib_arg)
58
 
  {
59
 
    flags|= ENUM_FLAG;
60
 
  }
61
 
  Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
62
 
  enum ha_base_keytype key_type() const;
63
 
  int  store(const char *to, uint32_t length, const CHARSET_INFO * const);
64
 
  int  store(double nr);
65
 
  int  store(int64_t nr, bool unsigned_val);
66
 
  double val_real(void);
67
 
  int64_t val_int(void);
68
 
  String *val_str(String*, String *);
69
 
  int cmp(const unsigned char *, const unsigned char *);
70
 
  void sort_string(unsigned char *buff, uint32_t length);
71
 
  void store_type(uint64_t value);
72
 
  void sql_type(String &str) const;
73
 
  bool eq_def(Field *field);
74
 
  enum_field_types type() const
75
 
  {
76
 
    return DRIZZLE_TYPE_ENUM;
77
 
  }
78
 
  enum Item_result cmp_type () const
79
 
  {
80
 
    return INT_RESULT;
81
 
  }
82
 
  enum Item_result cast_to_int_type () const
83
 
  {
84
 
    return INT_RESULT;
85
 
  }
86
 
  uint32_t pack_length() const
87
 
  {
88
 
    return (uint32_t) packlength;
89
 
  }
90
 
  uint32_t size_of() const
91
 
  {
92
 
    return sizeof(*this);
93
 
  }
94
 
  enum_field_types real_type() const
95
 
  {
96
 
    return DRIZZLE_TYPE_ENUM;
97
 
  }
98
 
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
99
 
  {
100
 
    return (field_metadata & 0x00ff);
101
 
  }
102
 
  virtual bool zero_pack() const
103
 
  {
104
 
    return false;
105
 
  }
106
 
  bool optimize_range(uint32_t, uint32_t) 
107
 
  {
108
 
    return false;
109
 
  }
110
 
  bool has_charset(void) const
111
 
  {
112
 
    return true;
113
 
  }
114
 
  /* enum and set are sorted as integers */
115
 
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
116
 
};
117
 
 
118
 
} /* namespace drizzled */
119
 
 
120
 
#endif /* DRIZZLED_FIELD_ENUM_H */