1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 MySQL
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.
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.
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
21
#ifndef DRIZZLE_SERVER_FIELD_STRING
22
#define DRIZZLE_SERVER_FIELD_STRING
24
#include "mysql_priv.h"
26
class Field_string :public Field_longstr {
28
bool can_alter_field_type;
29
Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
31
enum utype unireg_check_arg, const char *field_name_arg,
33
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
34
unireg_check_arg, field_name_arg, cs),
35
can_alter_field_type(1) {};
36
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
38
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
39
NONE, field_name_arg, cs),
40
can_alter_field_type(1) {};
42
enum_field_types type() const
44
return MYSQL_TYPE_STRING;
46
enum ha_base_keytype key_type() const
47
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
48
bool zero_pack() const { return 0; }
51
charset()->cset->fill(charset(),(char*) ptr, field_length,
52
(has_charset() ? ' ' : 0));
55
int store(const char *to,uint length,CHARSET_INFO *charset);
56
int store(int64_t nr, bool unsigned_val);
57
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
58
double val_real(void);
59
int64_t val_int(void);
60
String *val_str(String*,String *);
61
my_decimal *val_decimal(my_decimal *);
62
int cmp(const uchar *,const uchar *);
63
void sort_string(uchar *buff,uint length);
64
void sql_type(String &str) const;
65
virtual uchar *pack(uchar *to, const uchar *from,
66
uint max_length, bool low_byte_first);
67
virtual const uchar *unpack(uchar* to, const uchar *from,
68
uint param_data, bool low_byte_first);
69
uint pack_length_from_metadata(uint field_metadata)
70
{ return (field_metadata & 0x00ff); }
71
uint row_pack_length() { return (field_length + 1); }
72
int pack_cmp(const uchar *a,const uchar *b,uint key_length,
73
my_bool insert_or_update);
74
int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
75
uint packed_col_length(const uchar *to, uint length);
76
uint max_packed_col_length(uint max_length);
77
uint size_of() const { return sizeof(*this); }
78
enum_field_types real_type() const { return MYSQL_TYPE_STRING; }
79
bool has_charset(void) const
80
{ return charset() == &my_charset_bin ? false : true; }
81
Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
82
virtual uint get_key_image(uchar *buff,uint length, imagetype type);
84
int do_save_field_metadata(uchar *first_byte);