Loading mysql-test/r/type_binary.result +3 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,6 @@ select count(distinct s1) from t1; count(distinct s1) 3 drop table t1; select hex(cast(0x10 as binary(2))); hex(cast(0x10 as binary(2))) 1000 mysql-test/t/type_binary.test +3 −0 Original line number Diff line number Diff line Loading @@ -65,3 +65,6 @@ select hex(s1) from t1 where s1=0x0120; select hex(s1) from t1 where s1=0x0100; select count(distinct s1) from t1; drop table t1; # check that cast appends trailing zeros select hex(cast(0x10 as binary(2))); sql/item_timefunc.cc +29 −15 Original line number Diff line number Diff line Loading @@ -2352,8 +2352,9 @@ String *Item_char_typecast::val_str(String *str) and the result is longer than cast length, e.g. CAST('string' AS CHAR(1)) */ if (cast_length >= 0 && (res->length() > (length= (uint32) res->charpos(cast_length)))) if (cast_length >= 0) { if (res->length() > (length= (uint32) res->charpos(cast_length))) { // Safe even if const arg char char_type[40]; my_snprintf(char_type, sizeof(char_type), "CHAR(%lu)", length); Loading @@ -2369,6 +2370,19 @@ String *Item_char_typecast::val_str(String *str) res->c_ptr_safe()); res->length((uint) length); } else if (cast_cs == &my_charset_bin && res->length() < (uint) cast_length) { if (res->alloced_length() < (uint) cast_length) { str->alloc(cast_length); str->copy(*res); res= str; } bzero((char*) res->ptr() + res->length(), (uint) cast_length - res->length()); res->length(cast_length); } } null_value= 0; return res; } Loading Loading
mysql-test/r/type_binary.result +3 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,6 @@ select count(distinct s1) from t1; count(distinct s1) 3 drop table t1; select hex(cast(0x10 as binary(2))); hex(cast(0x10 as binary(2))) 1000
mysql-test/t/type_binary.test +3 −0 Original line number Diff line number Diff line Loading @@ -65,3 +65,6 @@ select hex(s1) from t1 where s1=0x0120; select hex(s1) from t1 where s1=0x0100; select count(distinct s1) from t1; drop table t1; # check that cast appends trailing zeros select hex(cast(0x10 as binary(2)));
sql/item_timefunc.cc +29 −15 Original line number Diff line number Diff line Loading @@ -2352,8 +2352,9 @@ String *Item_char_typecast::val_str(String *str) and the result is longer than cast length, e.g. CAST('string' AS CHAR(1)) */ if (cast_length >= 0 && (res->length() > (length= (uint32) res->charpos(cast_length)))) if (cast_length >= 0) { if (res->length() > (length= (uint32) res->charpos(cast_length))) { // Safe even if const arg char char_type[40]; my_snprintf(char_type, sizeof(char_type), "CHAR(%lu)", length); Loading @@ -2369,6 +2370,19 @@ String *Item_char_typecast::val_str(String *str) res->c_ptr_safe()); res->length((uint) length); } else if (cast_cs == &my_charset_bin && res->length() < (uint) cast_length) { if (res->alloced_length() < (uint) cast_length) { str->alloc(cast_length); str->copy(*res); res= str; } bzero((char*) res->ptr() + res->length(), (uint) cast_length - res->length()); res->length(cast_length); } } null_value= 0; return res; } Loading