Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2026 05/10/25 15:36:39 bar@stripped +3 -0
Bug#14255 CAST(x AS BINARY(N)) does not pad
type_binary.result, type_binary.test:
Adding test case.
item_timefunc.cc:
Padding code was added.
mysql-test/r/type_binary.result
1.2 05/10/25 15:35:54 bar@stripped +3 -0
Adding test case.
mysql-test/t/type_binary.test
1.2 05/10/25 15:35:49 bar@stripped +3 -0
Adding test case.
sql/item_timefunc.cc
1.95 05/10/25 15:35:21 bar@stripped +28 -14
Bug#14255 CAST(x AS BINARY(N)) does not pad
Padding code was added.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bar
# Host: bar.intranet.mysql.r18.ru
# Root: /usr/home/bar/mysql-5.0.b14255
--- 1.94/sql/item_timefunc.cc 2005-09-14 21:24:30 +05:00
+++ 1.95/sql/item_timefunc.cc 2005-10-25 15:35:21 +05:00
@@ -2327,22 +2327,36 @@
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))))
- { // Safe even if const arg
- char char_type[40];
- my_snprintf(char_type, sizeof(char_type), "CHAR(%lu)", 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);
- if (!res->alloced_length())
- { // Don't change const str
- str_value= *res; // Not malloced string
- res= &str_value;
+ if (!res->alloced_length())
+ { // Don't change const str
+ str_value= *res; // Not malloced string
+ res= &str_value;
+ }
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), char_type,
+ 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);
}
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), char_type,
- res->c_ptr_safe());
- res->length((uint) length);
}
null_value= 0;
return res;
--- 1.1/mysql-test/r/type_binary.result 2005-10-13 19:15:46 +05:00
+++ 1.2/mysql-test/r/type_binary.result 2005-10-25 15:35:54 +05:00
@@ -111,3 +111,6 @@
count(distinct s1)
3
drop table t1;
+select hex(cast(0x10 as binary(2)));
+hex(cast(0x10 as binary(2)))
+1000
--- 1.1/mysql-test/t/type_binary.test 2005-10-13 19:15:41 +05:00
+++ 1.2/mysql-test/t/type_binary.test 2005-10-25 15:35:49 +05:00
@@ -65,3 +65,6 @@
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)));
| Thread |
|---|
| • bk commit into 5.0 tree (bar:1.2026) BUG#14255 | bar | 25 Oct |