diff options
author | unknown <evgen@moonbone.local> | 2007-01-09 22:35:30 +0300 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2007-01-09 22:35:30 +0300 |
commit | 78dff026afa9ff1fbb02f6f2acc1569895f9c371 (patch) | |
tree | b2b5d4b30464556f41818cbd86897eeb615b12f2 | |
parent | f831f46ab2b110fcbad04db9108afe1416fea3ed (diff) | |
download | mariadb-git-78dff026afa9ff1fbb02f6f2acc1569895f9c371.tar.gz |
Bug#14171: Wrong internal default value for a BINARY field.
A BINARY field is represented by the Field_string class. The space character
is used as the filler for unused characters in such a field. But a BINARY field
should use \x00 instead.
Field_string:reset() now detects whether the current field is a BINARY one
and if so uses the \x00 character as a default value filler.
sql/field.h:
Bug#14171: Wrong internal default value for a BINARY field.
Field_string:reset() now detects whether the current field is a BINARY one
and if so uses the \x00 character as a default value filler.
mysql-test/r/type_binary.result:
Added a test case for the bug#14171: Wrong internal default value for a BINARY field.
mysql-test/t/type_binary.test:
Added a test case for the bug#14171: Wrong internal default value for a BINARY field.
-rw-r--r-- | mysql-test/r/type_binary.result | 9 | ||||
-rw-r--r-- | mysql-test/t/type_binary.test | 8 | ||||
-rw-r--r-- | sql/field.h | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/mysql-test/r/type_binary.result b/mysql-test/r/type_binary.result index 597defb7a9b..debf4ff8fb8 100644 --- a/mysql-test/r/type_binary.result +++ b/mysql-test/r/type_binary.result @@ -136,4 +136,13 @@ insert into t1 values(NULL, 0x412020); ERROR 22001: Data too long for column 'vb' at row 1 drop table t1; set @@sql_mode= @old_sql_mode; +create table t1(f1 int, f2 binary(2) not null, f3 char(2) not null); +insert into t1 set f1=1; +Warnings: +Warning 1364 Field 'f2' doesn't have a default value +Warning 1364 Field 'f3' doesn't have a default value +select hex(f2), hex(f3) from t1; +hex(f2) hex(f3) +0000 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_binary.test b/mysql-test/t/type_binary.test index 1639aff4711..91eba9b328e 100644 --- a/mysql-test/t/type_binary.test +++ b/mysql-test/t/type_binary.test @@ -91,4 +91,12 @@ insert into t1 values(NULL, 0x412020); drop table t1; set @@sql_mode= @old_sql_mode; +# +# Bug#14171: Wrong default value for a BINARY field +# +create table t1(f1 int, f2 binary(2) not null, f3 char(2) not null); +insert into t1 set f1=1; +select hex(f2), hex(f3) from t1; +drop table t1; + --echo End of 5.0 tests diff --git a/sql/field.h b/sql/field.h index d4bcdf556cf..103b596ae77 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1034,7 +1034,8 @@ public: bool zero_pack() const { return 0; } int reset(void) { - charset()->cset->fill(charset(),ptr,field_length,' '); + charset()->cset->fill(charset(),ptr,field_length, + (has_charset() ? ' ' : 0)); return 0; } int store(const char *to,uint length,CHARSET_INFO *charset); |