Below is the list of changes that have just been committed into a local
4.1 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.2336 05/07/11 13:20:07 bar@stripped +3 -0
field_conv.cc:
Bug#11591
CHAR column with utf8 does not work properly
(more chars than expected)
do_cut_string didn't call well_formed_length,
and copied all data, which was wrong in the
case of multibyte character set.
ctype_utf8.result, ctype_utf8.test:
adding test case
mysql-test/r/ctype_utf8.result
1.59 05/07/11 13:19:23 bar@stripped +11 -0
adding test caser
mysql-test/t/ctype_utf8.test
1.58 05/07/11 13:19:14 bar@stripped +10 -0
adding test case
sql/field_conv.cc
1.35 05/07/11 13:17:51 bar@stripped +19 -12
Bug#11591
CHAR column with utf8 does not work properly
(more chars than expected)
do_cut_string didn't call well_formed_length,
and copied all data, which was wrong in the
case of multibyte character set.
# 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-4.1.bug11591
--- 1.34/sql/field_conv.cc 2005-01-19 00:22:08 +04:00
+++ 1.35/sql/field_conv.cc 2005-07-11 13:17:51 +05:00
@@ -326,21 +326,28 @@
static void do_cut_string(Copy_field *copy)
{ // Shorter string field
- memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
+ int well_formed_error;
+ CHARSET_INFO *cs= copy->from_field->charset();
+ const char *from_end= copy->from_ptr + copy->from_length;
+ uint copy_length= cs->cset->well_formed_len(cs, copy->from_ptr, from_end,
+ copy->to_length / cs->mbmaxlen,
+ &well_formed_error);
+ if (copy->to_length < copy_length)
+ copy_length= copy->to_length;
+ memcpy(copy->to_ptr, copy->from_ptr, copy_length);
- /* Check if we loosed any important characters */
- char *ptr,*end;
- for
(ptr=copy->from_ptr+copy->to_length,end=copy->from_ptr+copy->from_length ;
- ptr != end ;
- ptr++)
+ /* Check if we lost any important characters */
+ if (well_formed_error ||
+ cs->cset->scan(cs, copy->from_ptr + copy_length, from_end,
+ MY_SEQ_SPACES) < (copy->from_length - copy_length))
{
- if (!my_isspace(system_charset_info, *ptr)) // QQ: ucs incompatible
- {
- copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DATA_TRUNCATED, 1);
- break;
- }
+ copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_DATA_TRUNCATED, 1);
}
+
+ if (copy_length < copy->to_length)
+ cs->cset->fill(cs, copy->to_ptr + copy_length,
+ copy->to_length - copy_length, ' ');
}
--- 1.58/mysql-test/r/ctype_utf8.result 2005-07-07 17:43:31 +05:00
+++ 1.59/mysql-test/r/ctype_utf8.result 2005-07-11 13:19:23 +05:00
@@ -939,6 +939,17 @@
ERR Имри.Афимим.Аеимимримдмримрмрирор
имримримримр имридм
ирбднримрфмририримрфмфмим.Ад.Д
имдимримрад.Адимримримрмдиримримримр
м.Дадимфшьмримд им.Адимимрн имадми 1234567890
11 g 1234567890
DROP TABLE t1,t2;
+create table t1 (a char(20) character set utf8);
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8;
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'a' at row 2
+select char_length(a), length(a), a from t1 order by a;
+char_length(a) length(a) a
+2 2 12
+2 4 ан
+drop table t1;
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
--- 1.57/mysql-test/t/ctype_utf8.test 2005-06-28 14:59:04 +05:00
+++ 1.58/mysql-test/t/ctype_utf8.test 2005-07-11 13:19:14 +05:00
@@ -790,6 +790,16 @@
DROP TABLE t1,t2;
#
+# Bug#11591: CHAR column with utf8 does not work properly
+# (more chars than expected)
+#
+create table t1 (a char(20) character set utf8);
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8;
+select char_length(a), length(a), a from t1 order by a;
+drop table t1;
+
+#
# Bug#9557 MyISAM utf8 table crash
#
CREATE TABLE t1 (
| Thread |
|---|
| • bk commit into 4.1 tree (bar:1.2336) BUG#11591 | bar | 11 Jul |