diff --git a/include/m_ctype.h b/include/m_ctype.h index 91bc0e67e64..e9a57024575 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -144,6 +144,8 @@ typedef struct charset_info_st int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, int radix, longlong val); + void (*fill)(struct charset_info_st *, char *to, uint len, int fill); + /* String-to-number convertion routines */ long (*strntol)(struct charset_info_st *, const char *s, uint l, int base, char **e, int *err); @@ -220,6 +222,8 @@ int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, longlong val); +void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); + my_bool my_like_range_simple(CHARSET_INFO *cs, const char *ptr, uint ptr_length, int escape, int w_one, int w_many, diff --git a/mysys/charset.c b/mysys/charset.c index 591ba568e3d..b1d20925eae 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -75,6 +75,7 @@ static void simple_cs_init_functions(CHARSET_INFO *cs) cs->snprintf = my_snprintf_8bit; cs->long10_to_str= my_long10_to_str_8bit; cs->longlong10_to_str= my_longlong10_to_str_8bit; + cs->fill = my_fill_8bit; cs->strntol = my_strntol_8bit; cs->strntoul = my_strntoul_8bit; cs->strntoll = my_strntoll_8bit; diff --git a/sql/field.cc b/sql/field.cc index 0fa306fe718..93ae5b81409 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3880,7 +3880,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) { memcpy(ptr,from,length); if (length < field_length) - bfill(ptr+length,field_length-length,' '); + field_charset->fill(field_charset,ptr+length,field_length-length,' '); } else { @@ -3888,14 +3888,12 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) if (current_thd->count_cuted_fields) { // Check if we loosed some info const char *end=from+length; - for (from+=field_length ; from != end ; from++) + from+= field_length; + from+= field_charset->scan(field_charset, from, end, MY_SEQ_SPACES); + if (from != end) { - if (!my_isspace(field_charset,*from)) - { - current_thd->cuted_fields++; - error=1; - break; - } + current_thd->cuted_fields++; + error=1; } } } diff --git a/sql/field.h b/sql/field.h index dc0b1b35d5b..f184c145b6e 100644 --- a/sql/field.h +++ b/sql/field.h @@ -788,7 +788,7 @@ public: enum ha_base_keytype key_type() const { return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; } bool zero_pack() const { return 0; } - void reset(void) { bfill(ptr,field_length,' '); } + void reset(void) { charset()->fill(charset(),ptr,field_length,' '); } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr); diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 37bf2aba509..e1cc0b6e8ab 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6258,7 +6258,8 @@ CHARSET_INFO my_charset_big5 = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, - + my_fill_8bit, + my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 48d5536a2cb..61f89e0a2cc 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -306,6 +306,7 @@ static CHARSET_INFO my_charset_bin_st = my_snprintf_8bit, /* snprintf */ my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 6397d3d902e..3e351732212 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -630,6 +630,7 @@ CHARSET_INFO my_charset_czech = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index d4eebdcb4a9..7a2fe48f4ab 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8676,6 +8676,7 @@ CHARSET_INFO my_charset_euc_kr = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index b01053866be..c0baca808cb 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5726,6 +5726,7 @@ CHARSET_INFO my_charset_gb2312 = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index c65c9f2123e..5db91d09cc8 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9913,6 +9913,7 @@ CHARSET_INFO my_charset_gbk = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-latin1_de.c b/strings/ctype-latin1_de.c index 6a5a9b78e8d..22aea5a2cad 100644 --- a/strings/ctype-latin1_de.c +++ b/strings/ctype-latin1_de.c @@ -448,6 +448,7 @@ CHARSET_INFO my_charset_latin1_de = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index aaa98fd4df2..d7d382a61c3 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1000,7 +1000,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) return 0; case MY_SEQ_SPACES: - for (; str != end ; str++) + for ( ; str < end ; str++) { if (!my_isspace(cs,*str)) break; @@ -1010,3 +1010,9 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) return 0; } } + +void my_fill_8bit(CHARSET_INFO *cs __attribute__((unused)), + char *s, uint l, int fill) +{ + bfill(s,l,fill); +} \ No newline at end of file diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 0408332ee30..b666bdf20d2 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4500,6 +4500,7 @@ CHARSET_INFO my_charset_sjis = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index ac959105736..5461173b766 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -722,6 +722,7 @@ CHARSET_INFO my_charset_tis620 = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 211b42db470..268a9e2296e 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8467,6 +8467,7 @@ CHARSET_INFO my_charset_ujis = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 3f859223a15..c4c12efe8b2 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2001,6 +2001,7 @@ CHARSET_INFO my_charset_utf8 = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3089,6 +3090,7 @@ CHARSET_INFO my_charset_ucs2 = my_snprintf_ucs2, my_l10tostr_ucs2, my_ll10tostr_ucs2, + my_fill_8bit, my_strntol_ucs2, my_strntoul_ucs2, my_strntoll_ucs2, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index b6e78368dde..f5074a4ec0e 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -666,6 +666,7 @@ CHARSET_INFO my_charset_win1250ch = my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, diff --git a/strings/ctype.c b/strings/ctype.c index 891c3c2c882..f656c4318a3 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -2845,6 +2845,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -2892,6 +2893,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -2938,6 +2940,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -2984,6 +2987,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3031,6 +3035,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3077,6 +3082,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3123,6 +3129,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3169,6 +3176,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3216,6 +3224,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3262,6 +3271,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3308,6 +3318,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3354,6 +3365,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3400,6 +3412,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3446,6 +3459,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3492,6 +3506,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3539,6 +3554,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3585,6 +3601,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3632,6 +3649,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3679,6 +3697,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3725,6 +3744,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3771,6 +3791,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3817,6 +3838,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3863,6 +3885,7 @@ static CHARSET_INFO compiled_charsets[] = { my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, + my_fill_8bit, my_strntol_8bit, my_strntoul_8bit, my_strntoll_8bit, @@ -3915,6 +3938,7 @@ static CHARSET_INFO compiled_charsets[] = { NULL, NULL, NULL, + NULL, NULL } };