740
class Field_short :public Field_num {
742
Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
744
enum utype unireg_check_arg, const char *field_name_arg,
745
bool zero_arg, bool unsigned_arg)
746
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
747
unireg_check_arg, field_name_arg,
748
0, zero_arg,unsigned_arg)
750
Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
752
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
753
NONE, field_name_arg, 0, 0, unsigned_arg)
755
enum Item_result result_type () const { return INT_RESULT; }
756
enum_field_types type() const { return MYSQL_TYPE_SHORT;}
757
enum ha_base_keytype key_type() const
758
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
759
int store(const char *to,uint length,CHARSET_INFO *charset);
760
int store(double nr);
761
int store(int64_t nr, bool unsigned_val);
762
int reset(void) { ptr[0]=ptr[1]=0; return 0; }
763
double val_real(void);
764
int64_t val_int(void);
765
String *val_str(String*,String *);
766
bool send_binary(Protocol *protocol);
767
int cmp(const uchar *,const uchar *);
768
void sort_string(uchar *buff,uint length);
769
uint32 pack_length() const { return 2; }
770
void sql_type(String &str) const;
771
uint32 max_display_length() { return 6; }
773
virtual uchar *pack(uchar* to, const uchar *from,
774
uint max_length __attribute__((__unused__)),
775
bool low_byte_first __attribute__((__unused__)))
778
#ifdef WORDS_BIGENDIAN
779
if (table->s->db_low_byte_first)
780
val = sint2korr(from);
785
#ifdef WORDS_BIGENDIAN
791
return to + sizeof(val);
794
virtual const uchar *unpack(uchar* to, const uchar *from,
795
uint param_data __attribute__((__unused__)),
796
bool low_byte_first __attribute__((__unused__)))
799
#ifdef WORDS_BIGENDIAN
801
val = sint2korr(from);
806
#ifdef WORDS_BIGENDIAN
807
if (table->s->db_low_byte_first)
812
return from + sizeof(val);
816
class Field_long :public Field_num {
818
Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
820
enum utype unireg_check_arg, const char *field_name_arg,
821
bool zero_arg, bool unsigned_arg)
822
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
823
unireg_check_arg, field_name_arg,
824
0, zero_arg,unsigned_arg)
826
Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
828
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
829
NONE, field_name_arg,0,0,unsigned_arg)
831
enum Item_result result_type () const { return INT_RESULT; }
832
enum_field_types type() const { return MYSQL_TYPE_LONG;}
833
enum ha_base_keytype key_type() const
834
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
835
int store(const char *to,uint length,CHARSET_INFO *charset);
836
int store(double nr);
837
int store(int64_t nr, bool unsigned_val);
838
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
839
double val_real(void);
840
int64_t val_int(void);
841
bool send_binary(Protocol *protocol);
842
String *val_str(String*,String *);
843
int cmp(const uchar *,const uchar *);
844
void sort_string(uchar *buff,uint length);
845
uint32 pack_length() const { return 4; }
846
void sql_type(String &str) const;
847
uint32 max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
848
virtual uchar *pack(uchar* to, const uchar *from,
849
uint max_length __attribute__((__unused__)),
850
bool low_byte_first __attribute__((__unused__)))
853
#ifdef WORDS_BIGENDIAN
854
if (table->s->db_low_byte_first)
855
val = sint4korr(from);
860
#ifdef WORDS_BIGENDIAN
866
return to + sizeof(val);
869
virtual const uchar *unpack(uchar* to, const uchar *from,
870
uint param_data __attribute__((__unused__)),
871
bool low_byte_first __attribute__((__unused__)))
874
#ifdef WORDS_BIGENDIAN
876
val = sint4korr(from);
881
#ifdef WORDS_BIGENDIAN
882
if (table->s->db_low_byte_first)
887
return from + sizeof(val);
892
class Field_int64_t :public Field_num {
894
Field_int64_t(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
896
enum utype unireg_check_arg, const char *field_name_arg,
897
bool zero_arg, bool unsigned_arg)
898
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
899
unireg_check_arg, field_name_arg,
900
0, zero_arg,unsigned_arg)
902
Field_int64_t(uint32 len_arg,bool maybe_null_arg,
903
const char *field_name_arg,
905
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
906
NONE, field_name_arg,0,0,unsigned_arg)
908
enum Item_result result_type () const { return INT_RESULT; }
909
enum_field_types type() const { return MYSQL_TYPE_LONGLONG;}
910
enum ha_base_keytype key_type() const
911
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
912
int store(const char *to,uint length,CHARSET_INFO *charset);
913
int store(double nr);
914
int store(int64_t nr, bool unsigned_val);
917
ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
920
double val_real(void);
921
int64_t val_int(void);
922
String *val_str(String*,String *);
923
bool send_binary(Protocol *protocol);
924
int cmp(const uchar *,const uchar *);
925
void sort_string(uchar *buff,uint length);
926
uint32 pack_length() const { return 8; }
927
void sql_type(String &str) const;
928
bool can_be_compared_as_int64_t() const { return true; }
929
uint32 max_display_length() { return 20; }
930
virtual uchar *pack(uchar* to, const uchar *from,
931
uint max_length __attribute__((__unused__)),
932
bool low_byte_first __attribute__((__unused__)))
935
#ifdef WORDS_BIGENDIAN
936
if (table->s->db_low_byte_first)
937
val = sint8korr(from);
940
int64_tget(val, from);
942
#ifdef WORDS_BIGENDIAN
947
int64_tstore(to, val);
948
return to + sizeof(val);
951
virtual const uchar *unpack(uchar* to, const uchar *from,
952
uint param_data __attribute__((__unused__)),
953
bool low_byte_first __attribute__((__unused__)))
956
#ifdef WORDS_BIGENDIAN
958
val = sint8korr(from);
961
int64_tget(val, from);
963
#ifdef WORDS_BIGENDIAN
964
if (table->s->db_low_byte_first)
968
int64_tstore(to, val);
969
return from + sizeof(val);
973
class Field_double :public Field_real {
975
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
977
enum utype unireg_check_arg, const char *field_name_arg,
978
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
979
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
980
unireg_check_arg, field_name_arg,
981
dec_arg, zero_arg, unsigned_arg)
983
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
985
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
986
NONE, field_name_arg, dec_arg, 0, 0)
988
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
989
uint8 dec_arg, my_bool not_fixed_arg)
990
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
991
NONE, field_name_arg, dec_arg, 0, 0)
992
{not_fixed= not_fixed_arg; }
993
enum_field_types type() const { return MYSQL_TYPE_DOUBLE;}
994
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
995
int store(const char *to,uint length,CHARSET_INFO *charset);
996
int store(double nr);
997
int store(int64_t nr, bool unsigned_val);
998
int reset(void) { bzero(ptr,sizeof(double)); return 0; }
999
double val_real(void);
1000
int64_t val_int(void);
1001
String *val_str(String*,String *);
1002
bool send_binary(Protocol *protocol);
1003
int cmp(const uchar *,const uchar *);
1004
void sort_string(uchar *buff,uint length);
1005
uint32 pack_length() const { return sizeof(double); }
1006
uint row_pack_length() { return pack_length(); }
1007
void sql_type(String &str) const;
1009
int do_save_field_metadata(uchar *first_byte);
1013
/* Everything saved in this will disappear. It will always return NULL */
1015
class Field_null :public Field_str {
1016
static uchar null[1];
1018
Field_null(uchar *ptr_arg, uint32 len_arg,
1019
enum utype unireg_check_arg, const char *field_name_arg,
1021
:Field_str(ptr_arg, len_arg, null, 1,
1022
unireg_check_arg, field_name_arg, cs)
1024
enum_field_types type() const { return MYSQL_TYPE_NULL;}
1025
int store(const char *to __attribute__((__unused__)),
1026
uint length __attribute__((__unused__)),
1027
CHARSET_INFO *cs __attribute__((__unused__)))
1028
{ null[0]=1; return 0; }
1029
int store(double nr __attribute__((__unused__)))
1030
{ null[0]=1; return 0; }
1031
int store(int64_t nr __attribute__((__unused__)),
1032
bool unsigned_val __attribute__((__unused__)))
1033
{ null[0]=1; return 0; }
1034
int store_decimal(const my_decimal *d __attribute__((__unused__)))
1035
{ null[0]=1; return 0; }
1038
double val_real(void)
1040
int64_t val_int(void)
1042
my_decimal *val_decimal(my_decimal *) { return 0; }
1043
String *val_str(String *value __attribute__((__unused__)),
1045
{ value2->length(0); return value2;}
1046
int cmp(const uchar *a __attribute__((__unused__)),
1047
const uchar *b __attribute__((__unused__))) { return 0;}
1048
void sort_string(uchar *buff __attribute__((__unused__)),
1049
uint length __attribute__((__unused__))) {}
1050
uint32 pack_length() const { return 0; }
1051
void sql_type(String &str) const;
1052
uint size_of() const { return sizeof(*this); }
1053
uint32 max_display_length() { return 4; }
1057
class Field_timestamp :public Field_str {
1059
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
1060
uchar *null_ptr_arg, uchar null_bit_arg,
1061
enum utype unireg_check_arg, const char *field_name_arg,
1062
TABLE_SHARE *share, CHARSET_INFO *cs);
1063
Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
1065
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
1066
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
1067
enum Item_result cmp_type () const { return INT_RESULT; }
1068
int store(const char *to,uint length,CHARSET_INFO *charset);
1069
int store(double nr);
1070
int store(int64_t nr, bool unsigned_val);
1071
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
1072
double val_real(void);
1073
int64_t val_int(void);
1074
String *val_str(String*,String *);
1075
bool send_binary(Protocol *protocol);
1076
int cmp(const uchar *,const uchar *);
1077
void sort_string(uchar *buff,uint length);
1078
uint32 pack_length() const { return 4; }
1079
void sql_type(String &str) const;
1080
bool can_be_compared_as_int64_t() const { return true; }
1081
bool zero_pack() const { return 0; }
1083
virtual void set_default()
1085
if (table->timestamp_field == this &&
1086
unireg_check != TIMESTAMP_UN_FIELD)
1089
Field::set_default();
1091
/* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
1092
inline long get_timestamp(my_bool *null_value)
1094
if ((*null_value= is_null()))
1096
#ifdef WORDS_BIGENDIAN
1097
if (table && table->s->db_low_byte_first)
1098
return sint4korr(ptr);
1104
inline void store_timestamp(my_time_t timestamp)
1106
#ifdef WORDS_BIGENDIAN
1107
if (table && table->s->db_low_byte_first)
1109
int4store(ptr,timestamp);
1113
longstore(ptr,(uint32) timestamp);
1115
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1116
bool get_time(MYSQL_TIME *ltime);
1117
timestamp_auto_set_type get_auto_set_type() const;
1121
class Field_year :public Field_tiny {
1123
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
1125
enum utype unireg_check_arg, const char *field_name_arg)
1126
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1127
unireg_check_arg, field_name_arg, 1, 1)
1129
enum_field_types type() const { return MYSQL_TYPE_YEAR;}
1130
int store(const char *to,uint length,CHARSET_INFO *charset);
1131
int store(double nr);
1132
int store(int64_t nr, bool unsigned_val);
1133
double val_real(void);
1134
int64_t val_int(void);
1135
String *val_str(String*,String *);
1136
bool send_binary(Protocol *protocol);
1137
void sql_type(String &str) const;
1138
bool can_be_compared_as_int64_t() const { return true; }
1142
class Field_newdate :public Field_str {
1144
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
1145
enum utype unireg_check_arg, const char *field_name_arg,
1147
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
1148
unireg_check_arg, field_name_arg, cs)
1150
Field_newdate(bool maybe_null_arg, const char *field_name_arg,
1152
:Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
1153
NONE, field_name_arg, cs) {}
1154
enum_field_types type() const { return MYSQL_TYPE_NEWDATE;}
1155
enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
1156
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
1157
enum Item_result cmp_type () const { return INT_RESULT; }
1158
int store(const char *to,uint length,CHARSET_INFO *charset);
1159
int store(double nr);
1160
int store(int64_t nr, bool unsigned_val);
1161
int store_time(MYSQL_TIME *ltime, timestamp_type type);
1162
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
1163
double val_real(void);
1164
int64_t val_int(void);
1165
String *val_str(String*,String *);
1166
bool send_binary(Protocol *protocol);
1167
int cmp(const uchar *,const uchar *);
1168
void sort_string(uchar *buff,uint length);
1169
uint32 pack_length() const { return 3; }
1170
void sql_type(String &str) const;
1171
bool can_be_compared_as_int64_t() const { return true; }
1172
bool zero_pack() const { return 1; }
1173
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1174
bool get_time(MYSQL_TIME *ltime);
1178
class Field_time :public Field_str {
1180
Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
1181
enum utype unireg_check_arg, const char *field_name_arg,
1183
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
1184
unireg_check_arg, field_name_arg, cs)
1186
Field_time(bool maybe_null_arg, const char *field_name_arg,
1188
:Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
1189
NONE, field_name_arg, cs) {}
1190
enum_field_types type() const { return MYSQL_TYPE_TIME;}
1191
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
1192
enum Item_result cmp_type () const { return INT_RESULT; }
1193
int store_time(MYSQL_TIME *ltime, timestamp_type type);
1194
int store(const char *to,uint length,CHARSET_INFO *charset);
1195
int store(double nr);
1196
int store(int64_t nr, bool unsigned_val);
1197
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
1198
double val_real(void);
1199
int64_t val_int(void);
1200
String *val_str(String*,String *);
1201
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
1202
bool send_binary(Protocol *protocol);
1203
bool get_time(MYSQL_TIME *ltime);
1204
int cmp(const uchar *,const uchar *);
1205
void sort_string(uchar *buff,uint length);
1206
uint32 pack_length() const { return 3; }
1207
void sql_type(String &str) const;
1208
bool can_be_compared_as_int64_t() const { return true; }
1209
bool zero_pack() const { return 1; }
1213
class Field_datetime :public Field_str {
1215
Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
1216
enum utype unireg_check_arg, const char *field_name_arg,
1218
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
1219
unireg_check_arg, field_name_arg, cs)
1221
Field_datetime(bool maybe_null_arg, const char *field_name_arg,
1223
:Field_str((uchar*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
1224
NONE, field_name_arg, cs) {}
1225
enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
1226
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
1227
enum Item_result cmp_type () const { return INT_RESULT; }
1228
uint decimals() const { return DATETIME_DEC; }
1229
int store(const char *to,uint length,CHARSET_INFO *charset);
1230
int store(double nr);
1231
int store(int64_t nr, bool unsigned_val);
1232
int store_time(MYSQL_TIME *ltime, timestamp_type type);
1235
ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
1238
double val_real(void);
1239
int64_t val_int(void);
1240
String *val_str(String*,String *);
1241
bool send_binary(Protocol *protocol);
1242
int cmp(const uchar *,const uchar *);
1243
void sort_string(uchar *buff,uint length);
1244
uint32 pack_length() const { return 8; }
1245
void sql_type(String &str) const;
1246
bool can_be_compared_as_int64_t() const { return true; }
1247
bool zero_pack() const { return 1; }
1248
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1249
bool get_time(MYSQL_TIME *ltime);
1253
class Field_string :public Field_longstr {
1255
bool can_alter_field_type;
1256
Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
1258
enum utype unireg_check_arg, const char *field_name_arg,
1260
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1261
unireg_check_arg, field_name_arg, cs),
1262
can_alter_field_type(1) {};
1263
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
1265
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1266
NONE, field_name_arg, cs),
1267
can_alter_field_type(1) {};
1269
enum_field_types type() const
1271
return MYSQL_TYPE_STRING;
1273
enum ha_base_keytype key_type() const
1274
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
1275
bool zero_pack() const { return 0; }
1278
charset()->cset->fill(charset(),(char*) ptr, field_length,
1279
(has_charset() ? ' ' : 0));
1282
int store(const char *to,uint length,CHARSET_INFO *charset);
1283
int store(int64_t nr, bool unsigned_val);
1284
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
1285
double val_real(void);
1286
int64_t val_int(void);
1287
String *val_str(String*,String *);
1288
my_decimal *val_decimal(my_decimal *);
1289
int cmp(const uchar *,const uchar *);
1290
void sort_string(uchar *buff,uint length);
1291
void sql_type(String &str) const;
1292
virtual uchar *pack(uchar *to, const uchar *from,
1293
uint max_length, bool low_byte_first);
1294
virtual const uchar *unpack(uchar* to, const uchar *from,
1295
uint param_data, bool low_byte_first);
1296
uint pack_length_from_metadata(uint field_metadata)
1297
{ return (field_metadata & 0x00ff); }
1298
uint row_pack_length() { return (field_length + 1); }
1299
int pack_cmp(const uchar *a,const uchar *b,uint key_length,
1300
my_bool insert_or_update);
1301
int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update);
1302
uint packed_col_length(const uchar *to, uint length);
1303
uint max_packed_col_length(uint max_length);
1304
uint size_of() const { return sizeof(*this); }
1305
enum_field_types real_type() const { return MYSQL_TYPE_STRING; }
1306
bool has_charset(void) const
1307
{ return charset() == &my_charset_bin ? false : true; }
1308
Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
1309
virtual uint get_key_image(uchar *buff,uint length, imagetype type);
1311
int do_save_field_metadata(uchar *first_byte);
1315
class Field_varstring :public Field_longstr {
1318
The maximum space available in a Field_varstring, in bytes. See
1321
static const uint MAX_SIZE;
1322
/* Store number of bytes used to store length (1 or 2) */
1323
uint32 length_bytes;
1324
Field_varstring(uchar *ptr_arg,
1325
uint32 len_arg, uint length_bytes_arg,
1326
uchar *null_ptr_arg, uchar null_bit_arg,
1327
enum utype unireg_check_arg, const char *field_name_arg,
1328
TABLE_SHARE *share, CHARSET_INFO *cs)
1329
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
1330
unireg_check_arg, field_name_arg, cs),
1331
length_bytes(length_bytes_arg)
1333
share->varchar_fields++;
1335
Field_varstring(uint32 len_arg,bool maybe_null_arg,
1336
const char *field_name_arg,
1337
TABLE_SHARE *share, CHARSET_INFO *cs)
1338
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1339
NONE, field_name_arg, cs),
1340
length_bytes(len_arg < 256 ? 1 :2)
1342
share->varchar_fields++;
1345
enum_field_types type() const { return MYSQL_TYPE_VARCHAR; }
1346
enum ha_base_keytype key_type() const;
1347
uint row_pack_length() { return field_length; }
1348
bool zero_pack() const { return 0; }
1349
int reset(void) { bzero(ptr,field_length+length_bytes); return 0; }
1350
uint32 pack_length() const { return (uint32) field_length+length_bytes; }
1351
uint32 key_length() const { return (uint32) field_length; }
1352
uint32 sort_length() const
1354
return (uint32) field_length + (field_charset == &my_charset_bin ?
1357
int store(const char *to,uint length,CHARSET_INFO *charset);
1358
int store(int64_t nr, bool unsigned_val);
1359
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
1360
double val_real(void);
1361
int64_t val_int(void);
1362
String *val_str(String*,String *);
1363
my_decimal *val_decimal(my_decimal *);
1364
int cmp_max(const uchar *, const uchar *, uint max_length);
1365
int cmp(const uchar *a,const uchar *b)
1367
return cmp_max(a, b, ~0L);
1369
void sort_string(uchar *buff,uint length);
1370
uint get_key_image(uchar *buff,uint length, imagetype type);
1371
void set_key_image(const uchar *buff,uint length);
1372
void sql_type(String &str) const;
1373
virtual uchar *pack(uchar *to, const uchar *from,
1374
uint max_length, bool low_byte_first);
1375
uchar *pack_key(uchar *to, const uchar *from, uint max_length, bool low_byte_first);
1376
uchar *pack_key_from_key_image(uchar* to, const uchar *from,
1377
uint max_length, bool low_byte_first);
1378
virtual const uchar *unpack(uchar* to, const uchar *from,
1379
uint param_data, bool low_byte_first);
1380
const uchar *unpack_key(uchar* to, const uchar *from,
1381
uint max_length, bool low_byte_first);
1382
int pack_cmp(const uchar *a, const uchar *b, uint key_length,
1383
my_bool insert_or_update);
1384
int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
1385
int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
1386
int key_cmp(const uchar *,const uchar*);
1387
int key_cmp(const uchar *str, uint length);
1388
uint packed_col_length(const uchar *to, uint length);
1389
uint max_packed_col_length(uint max_length);
1390
uint32 data_length();
1391
uint32 used_length();
1392
uint size_of() const { return sizeof(*this); }
1393
enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; }
1394
bool has_charset(void) const
1395
{ return charset() == &my_charset_bin ? false : true; }
1396
Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
1397
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
1398
uchar *new_ptr, uchar *new_null_ptr,
1400
uint is_equal(Create_field *new_field);
1401
void hash(ulong *nr, ulong *nr2);
1403
int do_save_field_metadata(uchar *first_byte);
1407
class Field_blob :public Field_longstr {
1410
String value; // For temporaries
1412
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
1413
enum utype unireg_check_arg, const char *field_name_arg,
1414
TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
1415
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
1417
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1418
NONE, field_name_arg, cs),
1423
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
1424
CHARSET_INFO *cs, bool set_packlength)
1425
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1426
NONE, field_name_arg, cs)
1432
uint32 l_char_length= len_arg/cs->mbmaxlen;
1433
packlength= l_char_length <= 255 ? 1 :
1434
l_char_length <= 65535 ? 2 :
1435
l_char_length <= 16777215 ? 3 : 4;
1438
Field_blob(uint32 packlength_arg)
1439
:Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
1440
packlength(packlength_arg) {}
1441
enum_field_types type() const { return MYSQL_TYPE_BLOB;}
1442
enum ha_base_keytype key_type() const
1443
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
1444
int store(const char *to,uint length,CHARSET_INFO *charset);
1445
int store(double nr);
1446
int store(int64_t nr, bool unsigned_val);
1447
double val_real(void);
1448
int64_t val_int(void);
1449
String *val_str(String*,String *);
1450
my_decimal *val_decimal(my_decimal *);
1451
int cmp_max(const uchar *, const uchar *, uint max_length);
1452
int cmp(const uchar *a,const uchar *b)
1453
{ return cmp_max(a, b, ~0L); }
1454
int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length);
1455
int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
1456
int key_cmp(const uchar *,const uchar*);
1457
int key_cmp(const uchar *str, uint length);
1458
uint32 key_length() const { return 0; }
1459
void sort_string(uchar *buff,uint length);
1460
uint32 pack_length() const
1461
{ return (uint32) (packlength+table->s->blob_ptr_size); }
1464
Return the packed length without the pointer size added.
1466
This is used to determine the size of the actual data in the row
1469
@returns The length of the raw data itself without the pointer.
1471
uint32 pack_length_no_ptr() const
1472
{ return (uint32) (packlength); }
1473
uint row_pack_length() { return pack_length_no_ptr(); }
1474
uint32 sort_length() const;
1475
virtual uint32 max_data_length() const
1477
return (uint32) (((uint64_t) 1 << (packlength*8)) -1);
1479
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
1480
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
1481
#ifndef WORDS_BIGENDIAN
1484
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number, bool low_byte_first);
1485
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
1487
store_length(i_ptr, i_packlength, i_number, table->s->db_low_byte_first);
1489
inline void store_length(uint32 number)
1491
store_length(ptr, packlength, number);
1495
Return the packed length plus the length of the data.
1497
This is used to determine the size of the data plus the
1498
packed length portion in the row data.
1500
@returns The length in the row plus the size of the data.
1502
uint32 get_packed_size(const uchar *ptr_arg, bool low_byte_first)
1503
{return packlength + get_length(ptr_arg, packlength, low_byte_first);}
1505
inline uint32 get_length(uint row_offset= 0)
1506
{ return get_length(ptr+row_offset, this->packlength, table->s->db_low_byte_first); }
1507
uint32 get_length(const uchar *ptr, uint packlength, bool low_byte_first);
1508
uint32 get_length(const uchar *ptr_arg)
1509
{ return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
1510
void put_length(uchar *pos, uint32 length);
1511
inline void get_ptr(uchar **str)
1513
memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
1515
inline void get_ptr(uchar **str, uint row_offset)
1517
memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*));
1519
inline void set_ptr(uchar *length, uchar *data)
1521
memcpy(ptr,length,packlength);
1522
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
1524
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
1526
uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
1527
store_length(ptr_ofs, packlength, length);
1528
memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*));
1530
inline void set_ptr(uint32 length, uchar *data)
1532
set_ptr_offset(0, length, data);
1534
uint get_key_image(uchar *buff,uint length, imagetype type);
1535
void set_key_image(const uchar *buff,uint length);
1536
void sql_type(String &str) const;
1541
if (value.copy((char*) tmp, get_length(), charset()))
1543
Field_blob::reset();
1546
tmp=(uchar*) value.ptr();
1547
memcpy_fixed(ptr+packlength,&tmp,sizeof(char*));
1550
virtual uchar *pack(uchar *to, const uchar *from,
1551
uint max_length, bool low_byte_first);
1552
uchar *pack_key(uchar *to, const uchar *from,
1553
uint max_length, bool low_byte_first);
1554
uchar *pack_key_from_key_image(uchar* to, const uchar *from,
1555
uint max_length, bool low_byte_first);
1556
virtual const uchar *unpack(uchar *to, const uchar *from,
1557
uint param_data, bool low_byte_first);
1558
const uchar *unpack_key(uchar* to, const uchar *from,
1559
uint max_length, bool low_byte_first);
1560
int pack_cmp(const uchar *a, const uchar *b, uint key_length,
1561
my_bool insert_or_update);
1562
int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
1563
uint packed_col_length(const uchar *col_ptr, uint length);
1564
uint max_packed_col_length(uint max_length);
1565
void free() { value.free(); }
1566
inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); }
1567
friend int field_conv(Field *to,Field *from);
1568
uint size_of() const { return sizeof(*this); }
1569
bool has_charset(void) const
1570
{ return charset() == &my_charset_bin ? false : true; }
1571
uint32 max_display_length();
1572
uint is_equal(Create_field *new_field);
1573
inline bool in_read_set() { return bitmap_is_set(table->read_set, field_index); }
1574
inline bool in_write_set() { return bitmap_is_set(table->write_set, field_index); }
1576
int do_save_field_metadata(uchar *first_byte);
1580
691
class Field_enum :public Field_str {
1582
693
uint packlength;