List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:July 22 2008 9:27am
Subject:push into mysql-6.0-backup branch (bar:2732) Bug#32390
View as plain text  
------------------------------------------------------------
revno: 2732
revision-id: bar@stripped
parent: azundris@stripped
committer: Alexander Barkov <bar@stripped>
branch nick: mysql-6.0.b32390v2
timestamp: Tue 2008-07-22 14:25:46 +0500
message:
  Bug#32390 Character sets: casting utf32 to/from date doesn't work
  Problem: insertion of CURRENT_TIME, CURRENT_DATE and CURRENT_TIMESTAMP
  into a varchar column didn't work for non-ASCII character sets
  like ucs2, utf16 and utf32. That happened because character set
  of the inserted value was specified as my_charset_bin.
  Fix:
  - for tricky character set we specify my_charset_latin1,
  which forces character set conversion and thus make insertion correct.
  - for non-tricky character set we still use my_charset_bin to
  avoid unnesessary conversion.
  
  
  - mysql-test/include/ctype_datetime.inc:
  A new shared test include file
  
  
  - mysql-test/r/ctype_ucs.result
  - mysql-test/r/ctype_utf16.result
  - mysql-test/r/ctype_utf32.result
  - mysql-test/t/ctype_ucs.test
  - mysql-test/t/ctype_utf16.test
  - mysql-test/t/ctype_utf32.test:
  Adding tests
  
  - sql/field.cc
  The fix itself: pass proper character set value to store().
added:
  mysql-test/include/ctype_datetime.inc
ctype_datetime.inc-20080722092544-bd6f7wadj8ej5jzz-1
modified:
  mysql-test/r/ctype_ucs.result 
sp1f-ctype_ucs.result-20030916112630-sohywipskzw3eqmbhfsqxqjteoun6t2g
  mysql-test/r/ctype_utf16.result
sp1f-ctype_utf16.result-20071022114329-26hdoohzzwy64tybfu4cz6vfra3xpqha
  mysql-test/r/ctype_utf32.result
sp1f-ctype_utf32.result-20071022114329-q7emau2hohs227pnl52uyc3mq2ssktj7
  mysql-test/t/ctype_ucs.test   
sp1f-ctype_ucs.test-20030916112631-7diba44oovwv3h5kqbswfqbveczwbrxv
  mysql-test/t/ctype_utf16.test 
sp1f-ctype_utf16.test-20071022114329-nlaygzmbikxmph2n4tqjod7hgebdpqul
  mysql-test/t/ctype_utf32.test 
sp1f-ctype_utf32.test-20071022114329-ilqabwd4bx3yk7mza7trbiboshbxqy56
  sql/field.cc                  
sp1f-field.cc-19700101030959-f4imaofclsea3n4fj4ow5m7havmyxa2r
=== added file 'mysql-test/include/ctype_datetime.inc'
--- a/mysql-test/include/ctype_datetime.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_datetime.inc	2008-07-22 09:25:46 +0000
@@ -0,0 +1,11 @@
+#
+# Bug#32390 Character sets: casting utf32 to/from date doesn't work
+#
+CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
+SET timestamp=1216359724;
+INSERT INTO t1 VALUES (current_date);
+INSERT INTO t1 VALUES (current_time);
+INSERT INTO t1 VALUES (current_timestamp);
+SELECT s1, hex(s1) FROM t1;
+DROP TABLE t1;
+SET timestamp=0;

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2008-07-16 10:39:12 +0000
+++ b/mysql-test/r/ctype_ucs.result	2008-07-22 09:25:46 +0000
@@ -1273,3 +1273,18 @@
 select hex(char(0x01020304 using ucs2));
 hex(char(0x01020304 using ucs2))
 01020304
+Start of 6.0 tests
+SET collation_connection=ucs2_general_ci;
+CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
+SET timestamp=1216359724;
+INSERT INTO t1 VALUES (current_date);
+INSERT INTO t1 VALUES (current_time);
+INSERT INTO t1 VALUES (current_timestamp);
+SELECT s1, hex(s1) FROM t1;
+s1	hex(s1)
+2008-07-18	0032003000300038002D00300037002D00310038
+08:42:04	00300038003A00340032003A00300034
+2008-07-18
08:42:04	0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034
+DROP TABLE t1;
+SET timestamp=0;
+SET NAMES latin1;

=== modified file 'mysql-test/r/ctype_utf16.result'
--- a/mysql-test/r/ctype_utf16.result	2007-12-06 08:52:29 +0000
+++ b/mysql-test/r/ctype_utf16.result	2008-07-22 09:25:46 +0000
@@ -1103,3 +1103,17 @@
 NULL
 drop table t1;
 set names latin1;
+SET collation_connection=utf16_general_ci;
+CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
+SET timestamp=1216359724;
+INSERT INTO t1 VALUES (current_date);
+INSERT INTO t1 VALUES (current_time);
+INSERT INTO t1 VALUES (current_timestamp);
+SELECT s1, hex(s1) FROM t1;
+s1	hex(s1)
+2008-07-18	0032003000300038002D00300037002D00310038
+08:42:04	00300038003A00340032003A00300034
+2008-07-18
08:42:04	0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034
+DROP TABLE t1;
+SET timestamp=0;
+SET NAMES latin1;

=== modified file 'mysql-test/r/ctype_utf32.result'
--- a/mysql-test/r/ctype_utf32.result	2008-07-18 13:30:53 +0000
+++ b/mysql-test/r/ctype_utf32.result	2008-07-22 09:25:46 +0000
@@ -1049,6 +1049,20 @@
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 drop table t1;
+SET collation_connection=utf32_general_ci;
+CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
+SET timestamp=1216359724;
+INSERT INTO t1 VALUES (current_date);
+INSERT INTO t1 VALUES (current_time);
+INSERT INTO t1 VALUES (current_timestamp);
+SELECT s1, hex(s1) FROM t1;
+s1	hex(s1)
+2008-07-18	000000320000003000000030000000380000002D00000030000000370000002D0000003100000038
+08:42:04	00000030000000380000003A00000034000000320000003A0000003000000034
+2008-07-18
08:42:04	000000320000003000000030000000380000002D00000030000000370000002D00000031000000380000002000000030000000380000003A00000034000000320000003A0000003000000034
+DROP TABLE t1;
+SET timestamp=0;
+SET NAMES latin1;
 set collation_connection=utf32_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-07-16 10:39:12 +0000
+++ b/mysql-test/t/ctype_ucs.test	2008-07-22 09:25:46 +0000
@@ -662,3 +662,12 @@
 select hex(char(0x0102 using ucs2));
 select hex(char(0x010203 using ucs2));
 select hex(char(0x01020304 using ucs2));
+
+--echo Start of 6.0 tests
+#
+# Test how character set works with date/time
+#
+SET collation_connection=ucs2_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+

=== modified file 'mysql-test/t/ctype_utf16.test'
--- a/mysql-test/t/ctype_utf16.test	2007-12-06 08:52:29 +0000
+++ b/mysql-test/t/ctype_utf16.test	2008-07-22 09:25:46 +0000
@@ -708,5 +708,13 @@
 set names latin1;
 
 #
+# Test how character set works with date/time
+#
+SET collation_connection=utf16_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+
+
+#
 ## TODO: add tests for all engines
 #

=== modified file 'mysql-test/t/ctype_utf32.test'
--- a/mysql-test/t/ctype_utf32.test	2008-07-18 13:30:53 +0000
+++ b/mysql-test/t/ctype_utf32.test	2008-07-22 09:25:46 +0000
@@ -742,6 +742,13 @@
 drop table t1;
 
 #
+# Test how character set works with date/time
+#
+SET collation_connection=utf32_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+
+#
 # Test basic regex functionality
 #
 set collation_connection=utf32_general_ci;

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2008-07-11 00:12:51 +0000
+++ b/sql/field.cc	2008-07-22 09:25:46 +0000
@@ -1763,7 +1763,9 @@
   ASSERT_COLUMN_MARKED_FOR_WRITE;
   char buff[MAX_DATE_STRING_REP_LENGTH];
   uint length= (uint) my_TIME_to_str(ltime, buff);
-  return store(buff, length, &my_charset_bin);
+  return store(buff, length,
+               (charset()->state & MY_CS_NONASCII) ?
+               &my_charset_latin1 : &my_charset_bin);
 }
 
 

Thread
push into mysql-6.0-backup branch (bar:2732) Bug#32390Alexander Barkov22 Jul