summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
commit6c279ad6a71c63cb595fde7c951aadb31c3dbebc (patch)
tree3603f88e1b3bd1e622edb182cccd882dd31ddc8a /sql/field.h
parentf271100836d8a91a775894ec36b869a66a3145e5 (diff)
downloadmariadb-git-6c279ad6a71c63cb595fde7c951aadb31c3dbebc.tar.gz
MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from 'size_t' to 'type', possible loss of data)
Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h81
1 files changed, 41 insertions, 40 deletions
diff --git a/sql/field.h b/sql/field.h
index d2274aaf7e8..d5d49bed551 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -216,7 +216,7 @@ protected:
my_decimal *buf)
{
DBUG_ASSERT(length < UINT_MAX32);
- m_error= str2my_decimal(mask, str, (uint) length, cs,
+ m_error= str2my_decimal(mask, str, length, cs,
buf, (const char **) &m_end_of_num);
// E_DEC_TRUNCATED means a very minor truncation: '1e-100' -> 0
m_edom= m_error && m_error != E_DEC_TRUNCATED;
@@ -314,7 +314,7 @@ protected:
return decimal_value;
}
- longlong longlong_from_hex_hybrid(const char *str, uint32 length)
+ longlong longlong_from_hex_hybrid(const char *str, size_t length)
{
const char *end= str + length;
const char *ptr= end - MY_MIN(length, sizeof(longlong));
@@ -824,8 +824,8 @@ public:
@retval false - conversion is needed
*/
virtual bool memcpy_field_possible(const Field *from) const= 0;
- virtual int store(const char *to, uint length,CHARSET_INFO *cs)=0;
- virtual int store_hex_hybrid(const char *str, uint length);
+ virtual int store(const char *to, size_t length,CHARSET_INFO *cs)=0;
+ virtual int store_hex_hybrid(const char *str, size_t length);
virtual int store(double nr)=0;
virtual int store(longlong nr, bool unsigned_val)=0;
virtual int store_decimal(const my_decimal *d)=0;
@@ -833,7 +833,7 @@ public:
virtual int store_timestamp(my_time_t timestamp, ulong sec_part);
int store_time(const MYSQL_TIME *ltime)
{ return store_time_dec(ltime, TIME_SECOND_PART_DIGITS); }
- int store(const char *to, uint length, CHARSET_INFO *cs,
+ int store(const char *to, size_t length, CHARSET_INFO *cs,
enum_check_fields check_level);
int store(const LEX_STRING *ls, CHARSET_INFO *cs)
{
@@ -1644,20 +1644,20 @@ class Field_num :public Field {
protected:
int check_edom_and_important_data_truncation(const char *type, bool edom,
CHARSET_INFO *cs,
- const char *str, uint length,
+ const char *str, size_t length,
const char *end_of_num);
int check_edom_and_truncation(const char *type, bool edom,
CHARSET_INFO *cs,
- const char *str, uint length,
+ const char *str, size_t length,
const char *end_of_num);
- int check_int(CHARSET_INFO *cs, const char *str, uint length,
+ int check_int(CHARSET_INFO *cs, const char *str, size_t length,
const char *int_end, int error)
{
return check_edom_and_truncation("integer",
error == MY_ERRNO_EDOM || str == int_end,
cs, str, length, int_end);
}
- bool get_int(CHARSET_INFO *cs, const char *from, uint len,
+ bool get_int(CHARSET_INFO *cs, const char *from, size_t len,
longlong *rnd, ulonglong unsigned_max,
longlong signed_min, longlong signed_max);
void prepend_zeros(String *value) const;
@@ -1744,8 +1744,8 @@ public:
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
- int store(const char *to,uint length,CHARSET_INFO *cs)=0;
- int store_hex_hybrid(const char *str, uint length)
+ int store(const char *to,size_t length,CHARSET_INFO *cs)=0;
+ int store_hex_hybrid(const char *str, size_t length)
{
return store(str, length, &my_charset_bin);
}
@@ -1828,7 +1828,7 @@ public:
/* base class for float and double and decimal (old one) */
class Field_real :public Field_num {
protected:
- double get_double(const char *str, uint length, CHARSET_INFO *cs, int *err);
+ double get_double(const char *str, size_t length, CHARSET_INFO *cs, int *err);
public:
bool not_fixed;
@@ -1884,7 +1884,7 @@ public:
return eq_def(from) ? get_identical_copy_func() : do_field_string;
}
int reset(void);
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
double val_real(void);
@@ -1943,7 +1943,7 @@ public:
bool store_value(const my_decimal *decimal_value);
bool store_value(const my_decimal *decimal_value, int *native_error);
void set_value_on_overflow(my_decimal *decimal_value, bool sign);
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_time_dec(const MYSQL_TIME *ltime, uint dec);
@@ -1989,7 +1989,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_tiny; }
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=0; return 0; }
@@ -2039,7 +2039,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_short; }
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=ptr[1]=0; return 0; }
@@ -2074,7 +2074,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_int24; }
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
@@ -2114,7 +2114,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_long; }
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
@@ -2160,7 +2160,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_longlong; }
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void)
@@ -2264,7 +2264,7 @@ public:
}
const Type_handler *type_handler() const { return &type_handler_float; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { bzero(ptr,sizeof(float)); return 0; }
@@ -2316,7 +2316,7 @@ public:
}
const Type_handler *type_handler() const { return &type_handler_double; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int reset(void) { bzero(ptr,sizeof(double)); return 0; }
@@ -2351,7 +2351,7 @@ public:
{
return do_field_string;
}
- int store(const char *to, uint length, CHARSET_INFO *cs)
+ int store(const char *to, size_t length, CHARSET_INFO *cs)
{ null[0]=1; return 0; }
int store(double nr) { null[0]=1; return 0; }
int store(longlong nr, bool unsigned_val) { null[0]=1; return 0; }
@@ -2394,7 +2394,7 @@ public:
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg)
{ flags|= BINARY_FLAG; }
- int store_hex_hybrid(const char *str, uint length)
+ int store_hex_hybrid(const char *str, size_t length)
{
return store(str, length, &my_charset_bin);
}
@@ -2471,7 +2471,7 @@ public:
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_time_dec(const MYSQL_TIME *ltime, uint dec);
@@ -2493,7 +2493,7 @@ public:
const Type_handler *type_handler() const { return &type_handler_timestamp; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
Copy_func *get_copy_func(const Field *from) const;
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_time_dec(const MYSQL_TIME *ltime, uint dec);
@@ -2696,7 +2696,7 @@ public:
}
return do_field_int;
}
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_time_dec(const MYSQL_TIME *ltime, uint dec);
@@ -2815,7 +2815,7 @@ public:
decimals() == from->decimals();
}
int store_time_dec(const MYSQL_TIME *ltime, uint dec);
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
@@ -3188,7 +3188,7 @@ public:
(has_charset() ? ' ' : 0));
return 0;
}
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
using Field_str::store;
double val_real(void);
longlong val_int(void);
@@ -3292,7 +3292,7 @@ public:
!compression_method() == !from->compression_method() &&
length_bytes == ((Field_varstring*) from)->length_bytes;
}
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
using Field_str::store;
double val_real(void);
longlong val_int(void);
@@ -3348,7 +3348,7 @@ public:
{ return compression_method_ptr; }
private:
Compression_method *compression_method_ptr;
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
using Field_str::store;
String *val_str(String *, String *);
double val_real(void);
@@ -3508,7 +3508,7 @@ public:
!compression_method() == !from->compression_method() &&
!table->copy_blobs;
}
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
using Field_str::store;
double val_real(void);
longlong val_int(void);
@@ -3551,9 +3551,10 @@ public:
void reset_fields() { bzero((uchar*) &value,sizeof(value)); bzero((uchar*) &read_value,sizeof(read_value)); }
uint32 get_field_buffer_size(void) { return value.alloced_length(); }
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number);
- inline void store_length(uint32 number)
+ inline void store_length(size_t number)
{
- store_length(ptr, packlength, number);
+ DBUG_ASSERT(number < UINT_MAX32);
+ store_length(ptr, packlength, (uint32)number);
}
inline uint32 get_length(uint row_offset= 0) const
{ return get_length(ptr+row_offset, this->packlength); }
@@ -3661,7 +3662,7 @@ public:
{ return compression_method_ptr; }
private:
Compression_method *compression_method_ptr;
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
using Field_str::store;
String *val_str(String *, String *);
double val_real(void);
@@ -3728,7 +3729,7 @@ public:
bool is_eq_func) const;
void sql_type(String &str) const;
uint is_equal(Create_field *new_field);
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
@@ -3755,7 +3756,7 @@ public:
};
uint gis_field_options_image(uchar *buff, List<Create_field> &create_fields);
-uint gis_field_options_read(const uchar *buf, uint buf_len,
+uint gis_field_options_read(const uchar *buf, size_t buf_len,
Field_geom::storage_type *st_type,uint *precision, uint *scale, uint *srid);
#endif /*HAVE_SPATIAL*/
@@ -3809,7 +3810,7 @@ public:
return save_in_field_str(to);
}
bool memcpy_field_possible(const Field *from) const { return false; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
double val_real(void);
@@ -3876,7 +3877,7 @@ public:
flags=(flags & ~ENUM_FLAG) | SET_FLAG;
}
int store_field(Field *from) { return from->save_in_field(this); }
- int store(const char *to,uint length,CHARSET_INFO *charset);
+ int store(const char *to,size_t length,CHARSET_INFO *charset);
int store(double nr) { return Field_set::store((longlong) nr, FALSE); }
int store(longlong nr, bool unsigned_val);
@@ -3932,7 +3933,7 @@ public:
}
int save_in_field(Field *to) { return to->store(val_int(), true); }
bool memcpy_field_possible(const Field *from) const { return false; }
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *);
@@ -4051,7 +4052,7 @@ public:
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint size_of() const { return sizeof(*this); }
- int store(const char *to, uint length, CHARSET_INFO *charset);
+ int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr) { return Field_bit::store(nr); }
int store(longlong nr, bool unsigned_val)
{ return Field_bit::store(nr, unsigned_val); }