~drizzle-trunk/drizzle/development

466 by Monty Taylor
Fixed modelines... these files are c++.
1
/* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
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_VARSTRING
22
#define DRIZZLE_SERVER_FIELD_VARSTRING
23
584.5.1 by Monty Taylor
Removed field includes from field.h.
24
#include <drizzled/field/longstr.h>
656.1.1 by Monty Taylor
OOOh doggie. Got rid of my_alloca.
25
#include <string>
584.5.1 by Monty Taylor
Removed field includes from field.h.
26
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
27
class Field_varstring :public Field_longstr {
28
public:
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
29
30
  using Field::store;
31
  using Field::pack;
32
  using Field::unpack;
33
  using Field::val_int;
34
  using Field::val_str;
35
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
36
  /*
37
    The maximum space available in a Field_varstring, in bytes. See
38
    length_bytes.
39
  */
482 by Brian Aker
Remove uint.
40
  static const uint32_t MAX_SIZE;
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
41
  /* Store number of bytes used to store length (1 or 2) */
205 by Brian Aker
uint32 -> uin32_t
42
  uint32_t length_bytes;
481 by Brian Aker
Remove all of uchar.
43
  Field_varstring(unsigned char *ptr_arg,
482 by Brian Aker
Remove uint.
44
                  uint32_t len_arg, uint32_t length_bytes_arg,
481 by Brian Aker
Remove all of uchar.
45
                  unsigned char *null_ptr_arg, unsigned char null_bit_arg,
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
46
                  enum utype unireg_check_arg, const char *field_name_arg,
47
                  TABLE_SHARE *share, const CHARSET_INFO * const cs);
205 by Brian Aker
uint32 -> uin32_t
48
  Field_varstring(uint32_t len_arg,bool maybe_null_arg,
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
49
                  const char *field_name_arg,
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
50
                  TABLE_SHARE *share, const CHARSET_INFO * const cs);
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
51
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
52
  enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
53
  enum ha_base_keytype key_type() const;
482 by Brian Aker
Remove uint.
54
  uint32_t row_pack_length() { return field_length; }
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
55
  bool zero_pack() const { return 0; }
212.6.1 by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file.
56
  int  reset(void) { memset(ptr, 0, field_length+length_bytes); return 0; }
205 by Brian Aker
uint32 -> uin32_t
57
  uint32_t pack_length() const { return (uint32_t) field_length+length_bytes; }
58
  uint32_t key_length() const { return (uint32_t) field_length; }
59
  uint32_t sort_length() const
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
60
  {
205 by Brian Aker
uint32 -> uin32_t
61
    return (uint32_t) field_length + (field_charset == &my_charset_bin ?
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
62
                                    length_bytes : 0);
63
  }
482 by Brian Aker
Remove uint.
64
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
65
66
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
67
  int  store(int64_t nr, bool unsigned_val);
68
  int  store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
69
  double val_real(void);
70
  int64_t val_int(void);
71
  String *val_str(String*,String *);
779.3.16 by Monty Taylor
Some Sun warning fixes.
72
  inline String *val_str(String *str) { return val_str(str, str); }
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
73
  my_decimal *val_decimal(my_decimal *);
481 by Brian Aker
Remove all of uchar.
74
  int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
779.3.16 by Monty Taylor
Some Sun warning fixes.
75
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
481 by Brian Aker
Remove all of uchar.
76
  int cmp(const unsigned char *a,const unsigned char *b)
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
77
  {
365.2.6 by Monty Taylor
Undid some stupid int->int16_t conversions.
78
    return cmp_max(a, b, UINT32_MAX);
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
79
  }
482 by Brian Aker
Remove uint.
80
  void sort_string(unsigned char *buff,uint32_t length);
81
  uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
656.1.1 by Monty Taylor
OOOh doggie. Got rid of my_alloca.
82
  uint32_t get_key_image(std::basic_string <unsigned char> &buff,
83
                         uint32_t length, imagetype type);
482 by Brian Aker
Remove uint.
84
  void set_key_image(const unsigned char *buff,uint32_t length);
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
85
  void sql_type(String &str) const;
481 by Brian Aker
Remove all of uchar.
86
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
779.3.16 by Monty Taylor
Some Sun warning fixes.
87
                              uint32_t max_length,
88
                              bool low_byte_first);
89
482 by Brian Aker
Remove uint.
90
  unsigned char *pack_key(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
481 by Brian Aker
Remove all of uchar.
91
  unsigned char *pack_key_from_key_image(unsigned char* to, const unsigned char *from,
482 by Brian Aker
Remove uint.
92
                                 uint32_t max_length, bool low_byte_first);
779.3.16 by Monty Taylor
Some Sun warning fixes.
93
  virtual const unsigned char *unpack(unsigned char* to,
94
                                      const unsigned char *from,
95
                                      uint32_t param_data,
96
                                      bool low_byte_first);
97
 
481 by Brian Aker
Remove all of uchar.
98
  const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
482 by Brian Aker
Remove uint.
99
                          uint32_t max_length, bool low_byte_first);
100
  int pack_cmp(const unsigned char *a, const unsigned char *b, uint32_t key_length,
275 by Brian Aker
Full removal of my_bool from central server.
101
               bool insert_or_update);
482 by Brian Aker
Remove uint.
102
  int pack_cmp(const unsigned char *b, uint32_t key_length,bool insert_or_update);
481 by Brian Aker
Remove all of uchar.
103
  int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
104
  int key_cmp(const unsigned char *,const unsigned char*);
482 by Brian Aker
Remove uint.
105
  int key_cmp(const unsigned char *str, uint32_t length);
106
  uint32_t packed_col_length(const unsigned char *to, uint32_t length);
107
  uint32_t max_packed_col_length(uint32_t max_length);
205 by Brian Aker
uint32 -> uin32_t
108
  uint32_t data_length();
109
  uint32_t used_length();
482 by Brian Aker
Remove uint.
110
  uint32_t size_of() const { return sizeof(*this); }
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
111
  enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
112
  bool has_charset(void) const
113
  { return charset() == &my_charset_bin ? false : true; }
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
114
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
115
  Field *new_key_field(MEM_ROOT *root, Table *new_table,
481 by Brian Aker
Remove all of uchar.
116
                       unsigned char *new_ptr, unsigned char *new_null_ptr,
482 by Brian Aker
Remove uint.
117
                       uint32_t new_null_bit);
118
  uint32_t is_equal(Create_field *new_field);
290 by Brian Aker
Update for ulong change over.
119
  void hash(uint32_t *nr, uint32_t *nr2);
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
120
private:
481 by Brian Aker
Remove all of uchar.
121
  int do_save_field_metadata(unsigned char *first_byte);
173.1.7 by Toru Maesaka
ripped out TIME and VARSTRING, moved to field/
122
};
123
124
#endif
125