~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

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 DRIZZLE_SERVER_FIELD_ENUM
22
 
#define DRIZZLE_SERVER_FIELD_ENUM
23
 
 
24
 
class Field_enum :public Field_str {
25
 
protected:
26
 
  uint32_t packlength;
27
 
public:
28
 
  TYPELIB *typelib;
29
 
  Field_enum(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
30
 
             unsigned char null_bit_arg,
31
 
             enum utype unireg_check_arg, const char *field_name_arg,
32
 
             uint32_t packlength_arg,
33
 
             TYPELIB *typelib_arg,
34
 
             const CHARSET_INFO * const charset_arg)
35
 
    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
36
 
               unireg_check_arg, field_name_arg, charset_arg),
37
 
    packlength(packlength_arg),typelib(typelib_arg)
38
 
  {
39
 
      flags|=ENUM_FLAG;
40
 
  }
41
 
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
42
 
  enum_field_types type() const { return DRIZZLE_TYPE_ENUM; }
43
 
  enum Item_result cmp_type () const { return INT_RESULT; }
44
 
  enum Item_result cast_to_int_type () const { return INT_RESULT; }
45
 
  enum ha_base_keytype key_type() const;
46
 
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
47
 
  int  store(double nr);
48
 
  int  store(int64_t nr, bool unsigned_val);
49
 
  double val_real(void);
50
 
  int64_t val_int(void);
51
 
  String *val_str(String*,String *);
52
 
  int cmp(const unsigned char *,const unsigned char *);
53
 
  void sort_string(unsigned char *buff,uint32_t length);
54
 
  uint32_t pack_length() const { return (uint32_t) packlength; }
55
 
  void store_type(uint64_t value);
56
 
  void sql_type(String &str) const;
57
 
  uint32_t size_of() const { return sizeof(*this); }
58
 
  enum_field_types real_type() const { return DRIZZLE_TYPE_ENUM; }
59
 
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
60
 
  { return (field_metadata & 0x00ff); }
61
 
  uint32_t row_pack_length() { return pack_length(); }
62
 
  virtual bool zero_pack() const { return 0; }
63
 
  bool optimize_range(uint32_t idx __attribute__((unused)),
64
 
                      uint32_t part __attribute__((unused)))
65
 
  { return 0; }
66
 
  bool eq_def(Field *field);
67
 
  bool has_charset(void) const { return true; }
68
 
  /* enum and set are sorted as integers */
69
 
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
70
 
private:
71
 
  int do_save_field_metadata(unsigned char *first_byte);
72
 
};
73
 
 
74
 
#endif