#At file:///home/bar/mysql-bzr/mysql-5.1.b35720/
2677 Alexander Barkov 2008-07-25
Bug#35720 ucs2 + pad_char_to_full_length = failure
Problem: with @@sql_mode=pad_char_to_full_length
a CHAR column returned additional garbage
after trailing space characters due to
incorrect my_charpos() call.
Fix: call my_charpos() with correct arguments.
modified:
mysql-test/r/ctype_ucs.result
mysql-test/t/ctype_ucs.test
sql/field.cc
per-file comments:
mysql-test/r/ctype_ucs.result
Adding tests
mysql-test/t/ctype_ucs.test
Adding tests
sql/field.cc
Call my_charpos with correct "num_characters" argument.
=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result 2008-03-26 09:51:16 +0000
+++ b/mysql-test/r/ctype_ucs.result 2008-07-25 09:29:39 +0000
@@ -1098,6 +1098,17 @@
select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and
(ucs2_general_ci,COERCIBLE) for operation '='
drop table t1;
+CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2);
+INSERT INTO t1 VALUES ('a');
+SET @@sql_mode=pad_char_to_full_length;
+SELECT HEX(s1) FROM t1;
+HEX(s1)
+00610020002000200020
+SET @@sql_mode=default;
+SELECT HEX(s1) FROM t1;
+HEX(s1)
+0061
+DROP TABLE t1;
set collation_connection=ucs2_general_ci;
drop table if exists t1;
create table t1 as
=== modified file 'mysql-test/t/ctype_ucs.test'
--- a/mysql-test/t/ctype_ucs.test 2008-03-26 09:51:16 +0000
+++ b/mysql-test/t/ctype_ucs.test 2008-07-25 09:29:39 +0000
@@ -678,6 +678,17 @@
select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
drop table t1;
+#
+# Bug#35720 ucs2 + pad_char_to_full_length = failure
+#
+CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2);
+INSERT INTO t1 VALUES ('a');
+SET @@sql_mode=pad_char_to_full_length;
+SELECT HEX(s1) FROM t1;
+SET @@sql_mode=default;
+SELECT HEX(s1) FROM t1;
+DROP TABLE t1;
+
set collation_connection=ucs2_general_ci;
--source include/ctype_regex.inc
set names latin1;
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2008-07-22 17:53:36 +0000
+++ b/sql/field.cc 2008-07-25 09:29:39 +0000
@@ -6610,7 +6610,8 @@
uint length;
if (table->in_use->variables.sql_mode &
MODE_PAD_CHAR_TO_FULL_LENGTH)
- length= my_charpos(field_charset, ptr, ptr + field_length, field_length);
+ length= my_charpos(field_charset, ptr, ptr + field_length,
+ field_length / field_charset->mbmaxlen);
else
length= field_charset->cset->lengthsp(field_charset, (const char*) ptr,
field_length);
| Thread |
|---|
| • commit into mysql-5.1 branch (bar:2677) Bug#35720 | Alexander Barkov | 25 Jul |