~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/field.h

  • Committer: Toru Maesaka
  • Date: 2008-07-18 07:06:52 UTC
  • mto: (202.1.1 toru)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: dev@torum.net-20080718070652-b6gbxq3pga4lj0x2
ripped out TIME and VARSTRING, moved to field/

Show diffs side-by-side

added added

removed removed

Lines of Context:
958
958
};
959
959
 
960
960
 
961
 
class Field_time :public Field_str {
962
 
public:
963
 
  Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
964
 
             enum utype unireg_check_arg, const char *field_name_arg,
965
 
             CHARSET_INFO *cs)
966
 
    :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
967
 
               unireg_check_arg, field_name_arg, cs)
968
 
    {}
969
 
  Field_time(bool maybe_null_arg, const char *field_name_arg,
970
 
             CHARSET_INFO *cs)
971
 
    :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
972
 
               NONE, field_name_arg, cs) {}
973
 
  enum_field_types type() const { return MYSQL_TYPE_TIME;}
974
 
  enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
975
 
  enum Item_result cmp_type () const { return INT_RESULT; }
976
 
  int store_time(MYSQL_TIME *ltime, timestamp_type type);
977
 
  int store(const char *to,uint length,CHARSET_INFO *charset);
978
 
  int store(double nr);
979
 
  int store(int64_t nr, bool unsigned_val);
980
 
  int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
981
 
  double val_real(void);
982
 
  int64_t val_int(void);
983
 
  String *val_str(String*,String *);
984
 
  bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
985
 
  bool send_binary(Protocol *protocol);
986
 
  bool get_time(MYSQL_TIME *ltime);
987
 
  int cmp(const uchar *,const uchar *);
988
 
  void sort_string(uchar *buff,uint length);
989
 
  uint32 pack_length() const { return 3; }
990
 
  void sql_type(String &str) const;
991
 
  bool can_be_compared_as_int64_t() const { return true; }
992
 
  bool zero_pack() const { return 1; }
993
 
};
994
 
 
995
 
 
996
961
class Field_string :public Field_longstr {
997
962
public:
998
963
  bool can_alter_field_type;
1055
1020
};
1056
1021
 
1057
1022
 
1058
 
class Field_varstring :public Field_longstr {
1059
 
public:
1060
 
  /*
1061
 
    The maximum space available in a Field_varstring, in bytes. See
1062
 
    length_bytes.
1063
 
  */
1064
 
  static const uint MAX_SIZE;
1065
 
  /* Store number of bytes used to store length (1 or 2) */
1066
 
  uint32 length_bytes;
1067
 
  Field_varstring(uchar *ptr_arg,
1068
 
                  uint32 len_arg, uint length_bytes_arg,
1069
 
                  uchar *null_ptr_arg, uchar null_bit_arg,
1070
 
                  enum utype unireg_check_arg, const char *field_name_arg,
1071
 
                  TABLE_SHARE *share, CHARSET_INFO *cs)
1072
 
    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1073
 
                   unireg_check_arg, field_name_arg, cs),
1074
 
     length_bytes(length_bytes_arg)
1075
 
  {
1076
 
    share->varchar_fields++;
1077
 
  }
1078
 
  Field_varstring(uint32 len_arg,bool maybe_null_arg,
1079
 
                  const char *field_name_arg,
1080
 
                  TABLE_SHARE *share, CHARSET_INFO *cs)
1081
 
    :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1082
 
                   NONE, field_name_arg, cs),
1083
 
     length_bytes(len_arg < 256 ? 1 :2)
1084
 
  {
1085
 
    share->varchar_fields++;
1086
 
  }
1087
 
 
1088
 
  enum_field_types type() const { return MYSQL_TYPE_VARCHAR; }
1089
 
  enum ha_base_keytype key_type() const;
1090
 
  uint row_pack_length() { return field_length; }
1091
 
  bool zero_pack() const { return 0; }
1092
 
  int  reset(void) { bzero(ptr,field_length+length_bytes); return 0; }
1093
 
  uint32 pack_length() const { return (uint32) field_length+length_bytes; }
1094
 
  uint32 key_length() const { return (uint32) field_length; }
1095
 
  uint32 sort_length() const
1096
 
  {
1097
 
    return (uint32) field_length + (field_charset == &my_charset_bin ?
1098
 
                                    length_bytes : 0);
1099
 
  }
1100
 
  int  store(const char *to,uint length,CHARSET_INFO *charset);
1101
 
  int  store(int64_t nr, bool unsigned_val);
1102
 
  int  store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
1103
 
  double val_real(void);
1104
 
  int64_t val_int(void);
1105
 
  String *val_str(String*,String *);
1106
 
  my_decimal *val_decimal(my_decimal *);
1107
 
  int cmp_max(const uchar *, const uchar *, uint max_length);
1108
 
  int cmp(const uchar *a,const uchar *b)
1109
 
  {
1110
 
    return cmp_max(a, b, ~0L);
1111
 
  }
1112
 
  void sort_string(uchar *buff,uint length);
1113
 
  uint get_key_image(uchar *buff,uint length, imagetype type);
1114
 
  void set_key_image(const uchar *buff,uint length);
1115
 
  void sql_type(String &str) const;
1116
 
  virtual uchar *pack(uchar *to, const uchar *from,
1117
 
                      uint max_length, bool low_byte_first);
1118
 
  uchar *pack_key(uchar *to, const uchar *from, uint max_length, bool low_byte_first);
1119
 
  uchar *pack_key_from_key_image(uchar* to, const uchar *from,
1120
 
                                 uint max_length, bool low_byte_first);
1121
 
  virtual const uchar *unpack(uchar* to, const uchar *from,
1122
 
                              uint param_data, bool low_byte_first);
1123
 
  const uchar *unpack_key(uchar* to, const uchar *from,
1124
 
                          uint max_length, bool low_byte_first);
1125
 
  int pack_cmp(const uchar *a, const uchar *b, uint key_length,
1126
 
               my_bool insert_or_update);
1127
 
  int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
1128
 
  int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
1129
 
  int key_cmp(const uchar *,const uchar*);
1130
 
  int key_cmp(const uchar *str, uint length);
1131
 
  uint packed_col_length(const uchar *to, uint length);
1132
 
  uint max_packed_col_length(uint max_length);
1133
 
  uint32 data_length();
1134
 
  uint32 used_length();
1135
 
  uint size_of() const { return sizeof(*this); }
1136
 
  enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; }
1137
 
  bool has_charset(void) const
1138
 
  { return charset() == &my_charset_bin ? false : true; }
1139
 
  Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
1140
 
  Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
1141
 
                       uchar *new_ptr, uchar *new_null_ptr,
1142
 
                       uint new_null_bit);
1143
 
  uint is_equal(Create_field *new_field);
1144
 
  void hash(ulong *nr, ulong *nr2);
1145
 
private:
1146
 
  int do_save_field_metadata(uchar *first_byte);
1147
 
};
1148
 
 
1149
 
 
1150
1023
class Field_enum :public Field_str {
1151
1024
protected:
1152
1025
  uint packlength;
1357
1230
#include "field/year.h"
1358
1231
#include "field/new_date.h"
1359
1232
#include "field/new_decimal.h"
 
1233
#include "field/timetype.h"
1360
1234
#include "field/timestamp.h"
1361
1235
#include "field/datetime.h"
 
1236
#include "field/varstring.h"
1362
1237
 
1363
1238
/*
1364
1239
  The following are for the interface with the .frm file