~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/fstring.h

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

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_STRING
22
 
#define DRIZZLE_SERVER_FIELD_STRING
23
 
 
24
 
class Field_string :public Field_longstr {
25
 
public:
26
 
  bool can_alter_field_type;
27
 
  Field_string(uchar *ptr_arg, uint32_t len_arg,uchar *null_ptr_arg,
28
 
               uchar null_bit_arg,
29
 
               enum utype unireg_check_arg, const char *field_name_arg,
30
 
               const CHARSET_INFO * const cs)
31
 
    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
32
 
                   unireg_check_arg, field_name_arg, cs),
33
 
     can_alter_field_type(1) {};
34
 
  Field_string(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
35
 
               const CHARSET_INFO * const cs)
36
 
    :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
37
 
                   NONE, field_name_arg, cs),
38
 
     can_alter_field_type(1) {};
39
 
 
40
 
  enum_field_types type() const
41
 
  {
42
 
    return  DRIZZLE_TYPE_VARCHAR;
43
 
  }
44
 
  enum ha_base_keytype key_type() const
45
 
    { return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
46
 
  bool zero_pack() const { return 0; }
47
 
  int reset(void)
48
 
  {
49
 
    charset()->cset->fill(charset(),(char*) ptr, field_length,
50
 
                          (has_charset() ? ' ' : 0));
51
 
    return 0;
52
 
  }
53
 
  int store(const char *to,uint length, const CHARSET_INFO * const charset);
54
 
  int store(int64_t nr, bool unsigned_val);
55
 
  int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
56
 
  double val_real(void);
57
 
  int64_t val_int(void);
58
 
  String *val_str(String*,String *);
59
 
  my_decimal *val_decimal(my_decimal *);
60
 
  int cmp(const uchar *,const uchar *);
61
 
  void sort_string(uchar *buff,uint length);
62
 
  void sql_type(String &str) const;
63
 
  virtual uchar *pack(uchar *to, const uchar *from,
64
 
                      uint max_length, bool low_byte_first);
65
 
  virtual const uchar *unpack(uchar* to, const uchar *from,
66
 
                              uint param_data, bool low_byte_first);
67
 
  uint pack_length_from_metadata(uint field_metadata)
68
 
  { return (field_metadata & 0x00ff); }
69
 
  uint row_pack_length() { return (field_length + 1); }
70
 
  int pack_cmp(const uchar *a,const uchar *b,uint key_length,
71
 
               bool insert_or_update);
72
 
  int pack_cmp(const uchar *b,uint key_length,bool insert_or_update);
73
 
  uint packed_col_length(const uchar *to, uint length);
74
 
  uint max_packed_col_length(uint max_length);
75
 
  uint size_of() const { return sizeof(*this); }
76
 
  enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
77
 
  bool has_charset(void) const
78
 
  { return charset() == &my_charset_bin ? false : true; }
79
 
  Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
80
 
  virtual uint get_key_image(uchar *buff,uint length, imagetype type);
81
 
private:
82
 
  int do_save_field_metadata(uchar *first_byte);
83
 
};
84
 
 
85
 
#endif /* DRIZZLE_SERVER_FIELD_STRING */