@@ -6968,23 +6968,23 @@ int Field_string::store(const char *from, size_t length,CHARSET_INFO *cs)
6968
6968
{
6969
6969
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
6970
6970
uint copy_length;
6971
- String_copier copier ;
6971
+ int rc ;
6972
6972
6973
6973
/* See the comment for Field_long::store(long long) */
6974
6974
DBUG_ASSERT (!table || table->in_use == current_thd);
6975
6975
6976
- copy_length= copier. well_formed_copy (field_charset ,
6977
- ( char *) ptr, field_length ,
6978
- cs, from, length ,
6979
- field_length / field_charset-> mbmaxlen );
6976
+ rc= well_formed_copy_with_check (( char *) ptr, field_length ,
6977
+ cs, from, length ,
6978
+ field_length / field_charset-> mbmaxlen ,
6979
+ false , ©_length );
6980
6980
6981
6981
/* Append spaces if the string was shorter than the field. */
6982
6982
if (copy_length < field_length)
6983
6983
field_charset->cset ->fill (field_charset,(char *) ptr+copy_length,
6984
6984
field_length-copy_length,
6985
6985
field_charset->pad_char );
6986
6986
6987
- return check_conversion_status (&copier, from + length, cs, false ) ;
6987
+ return rc ;
6988
6988
}
6989
6989
6990
6990
@@ -7517,19 +7517,16 @@ int Field_varstring::store(const char *from,size_t length,CHARSET_INFO *cs)
7517
7517
{
7518
7518
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
7519
7519
uint copy_length;
7520
- String_copier copier ;
7520
+ int rc ;
7521
7521
7522
- copy_length= copier.well_formed_copy (field_charset,
7523
- (char *) ptr + length_bytes,
7524
- field_length,
7525
- cs, from, length,
7526
- field_length / field_charset->mbmaxlen );
7527
- if (length_bytes == 1 )
7528
- *ptr= (uchar) copy_length;
7529
- else
7530
- int2store (ptr, copy_length);
7522
+ rc= well_formed_copy_with_check ((char *) get_data (), field_length,
7523
+ cs, from, length,
7524
+ field_length / field_charset->mbmaxlen ,
7525
+ true , ©_length);
7531
7526
7532
- return check_conversion_status (&copier, from + length, cs, true );
7527
+ store_length (copy_length);
7528
+
7529
+ return rc;
7533
7530
}
7534
7531
7535
7532
@@ -7952,7 +7949,7 @@ void Field_varstring::hash(ulong *nr, ulong *nr2)
7952
7949
7953
7950
int Field_longstr::compress (char *to, uint *to_length,
7954
7951
const char *from, uint length,
7955
- CHARSET_INFO *cs)
7952
+ CHARSET_INFO *cs, size_t nchars )
7956
7953
{
7957
7954
THD *thd= get_thd ();
7958
7955
char *buf= 0 ;
@@ -7961,19 +7958,14 @@ int Field_longstr::compress(char *to, uint *to_length,
7961
7958
if (String::needs_conversion_on_storage (length, cs, field_charset) ||
7962
7959
*to_length <= length)
7963
7960
{
7964
- String_copier copier;
7965
- const char *end= from + length;
7966
-
7967
7961
if (!(buf= (char *) my_malloc (*to_length - 1 , MYF (MY_WME))))
7968
7962
{
7969
7963
*to_length= 0 ;
7970
7964
return -1 ;
7971
7965
}
7972
7966
7973
- length= copier.well_formed_copy (field_charset, buf, *to_length - 1 ,
7974
- cs, from, length,
7975
- (*to_length - 1 ) / field_charset->mbmaxlen );
7976
- rc= check_conversion_status (&copier, end, cs, true );
7967
+ rc= well_formed_copy_with_check (buf, *to_length - 1 , cs, from, length,
7968
+ nchars, true , &length);
7977
7969
from= buf;
7978
7970
}
7979
7971
@@ -8045,7 +8037,8 @@ int Field_varstring_compressed::store(const char *from, size_t length,
8045
8037
{
8046
8038
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
8047
8039
uint to_length= (uint)MY_MIN (field_length, field_charset->mbmaxlen * length + 1 );
8048
- int rc= compress ((char *) get_data (), &to_length, from, (uint)length, cs);
8040
+ int rc= compress ((char *) get_data (), &to_length, from, (uint) length, cs,
8041
+ (to_length - 1 ) / field_charset->mbmaxlen );
8049
8042
store_length (to_length);
8050
8043
return rc;
8051
8044
}
@@ -8174,10 +8167,11 @@ int Field_blob::store(const char *from,size_t length,CHARSET_INFO *cs)
8174
8167
{
8175
8168
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
8176
8169
size_t copy_length, new_length;
8177
- String_copier copier ;
8170
+ uint copy_len ;
8178
8171
char *tmp;
8179
8172
char buff[STRING_BUFFER_USUAL_SIZE];
8180
8173
String tmpstr (buff,sizeof (buff), &my_charset_bin);
8174
+ int rc;
8181
8175
8182
8176
if (!length)
8183
8177
{
@@ -8244,13 +8238,13 @@ int Field_blob::store(const char *from,size_t length,CHARSET_INFO *cs)
8244
8238
bmove (ptr + packlength, (uchar*) &tmp, sizeof (char *));
8245
8239
return 0 ;
8246
8240
}
8247
- copy_length= copier. well_formed_copy (field_charset ,
8248
- ( char *) value. ptr (), (uint)new_length ,
8249
- cs, from, length );
8250
- Field_blob::store_length (copy_length );
8241
+ rc= well_formed_copy_with_check (( char *) value. ptr (), (uint) new_length ,
8242
+ cs, from, length ,
8243
+ length, true , ©_len );
8244
+ Field_blob::store_length (copy_len );
8251
8245
bmove (ptr+packlength,(uchar*) &tmp,sizeof (char *));
8252
8246
8253
- return check_conversion_status (&copier, from + length, cs, true ) ;
8247
+ return rc ;
8254
8248
8255
8249
oom_error:
8256
8250
/* Fatal OOM error */
@@ -8664,7 +8658,8 @@ int Field_blob_compressed::store(const char *from, size_t length,
8664
8658
if (value.alloc (to_length))
8665
8659
goto oom;
8666
8660
8667
- rc= compress ((char *) value.ptr (), &to_length, tmp.ptr (), (uint) length, cs);
8661
+ rc= compress ((char *) value.ptr (), &to_length, tmp.ptr (), (uint) length, cs,
8662
+ (uint) length);
8668
8663
set_ptr (to_length, (uchar*) value.ptr ());
8669
8664
return rc;
8670
8665
0 commit comments