2740 Alexander Barkov 2008-09-15
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
2739 Martin Skold 2008-09-15
bug #31231 mysql_alter_table() tries to drop a non-existing table
bug#31233 mysql_alter_table() fails to drop UNIQUE KEY
modified:
mysql-test/suite/ndb/r/ndb_alter_table.result
mysql-test/suite/ndb/t/ndb_alter_table.test
sql/ha_ndbcluster.cc
sql/mysql_priv.h
sql/sql_table.cc
=== 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-09-15 10:29:31 +0000
@@ -1098,6 +1098,17 @@ ERROR HY000: Illegal mix of collations (
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-09-15 10:29:31 +0000
@@ -678,6 +678,17 @@ select * from t1 where a=if(b<10,_ucs2 0
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-09-15 10:29:31 +0000
@@ -6610,7 +6610,8 @@ String *Field_string::val_str(String *va
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 |
|---|
| • bzr push into mysql-5.1 branch (bar:2739 to 2740) Bug#35720 | Alexander Barkov | 15 Sep |