#At file:///home/bar/mysql-bzr/mysql-5.5-bugteam.b58321/ based on revid:gleb.shchepa@stripped
3195 Alexander Barkov 2010-12-15
Bug#58321 No warning when characters outside BMP0 is converted to UCS2
Problem: when inserting supplementary characters to an UCS2 column,
character was silently shrinked to 16-bit value.
Fix: produce a warning on attempt to insert a supplementary character,
and convert to question mark.
@ mysql-test/r/ctype_many.result
@ mysql-test/t/ctype_many.test
Adding tests
@ strings/ctype-ucs2.c
Check if wc is greater than the highest value supported (0xFFFF),
return MY_CS_ILUNI if true.
modified:
mysql-test/r/ctype_many.result
mysql-test/t/ctype_many.test
strings/ctype-ucs2.c
=== modified file 'mysql-test/r/ctype_many.result'
--- a/mysql-test/r/ctype_many.result 2010-02-24 09:15:34 +0000
+++ b/mysql-test/r/ctype_many.result 2010-12-15 09:58:37 +0000
@@ -1684,6 +1684,9 @@ ARMENIAN CAPIT ECH 2
ARMENIAN CAPIT ZA 2
DROP TABLE t1;
#
+# Start of 5.5 tests
+#
+#
# WL#1213 Implement 4-byte UTF8, UTF16 and UTF32
# Testing that only utf8mb4 is superset for utf8
# No other Unicode character set pairs have superset/subset relations
@@ -1739,3 +1742,22 @@ ERROR HY000: Illegal mix of collations (
SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1;
ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat'
DROP TABLE t1;
+#
+# Bug#58321 No warning when characters outside BMP0 is converted to UCS2
+#
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (0x10082), (0x12345);
+INSERT INTO t2 SELECT * FROM t1;
+Warnings:
+Warning 1366 Incorrect string value: '\x00\x01\x00\x82' for column 'a' at row 1
+Warning 1366 Incorrect string value: '\x00\x01\x23\x45' for column 'a' at row 2
+SELECT HEX(a) FROM t2;
+HEX(a)
+003F
+003F
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# End of 5.5 tests
+#
=== modified file 'mysql-test/t/ctype_many.test'
--- a/mysql-test/t/ctype_many.test 2010-02-24 09:15:34 +0000
+++ b/mysql-test/t/ctype_many.test 2010-12-15 09:58:37 +0000
@@ -217,6 +217,10 @@ DROP TABLE t1;
--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
--echo # WL#1213 Implement 4-byte UTF8, UTF16 and UTF32
--echo # Testing that only utf8mb4 is superset for utf8
--echo # No other Unicode character set pairs have superset/subset relations
@@ -284,3 +288,19 @@ SELECT CHARSET(CONCAT(utf32, utf8mb4)) F
SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#58321 No warning when characters outside BMP0 is converted to UCS2
+--echo #
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (0x10082), (0x12345);
+INSERT INTO t2 SELECT * FROM t1;
+SELECT HEX(a) FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
=== modified file 'strings/ctype-ucs2.c'
--- a/strings/ctype-ucs2.c 2010-11-26 10:44:39 +0000
+++ b/strings/ctype-ucs2.c 2010-12-15 09:58:37 +0000
@@ -2693,7 +2693,10 @@ static int my_uni_ucs2(CHARSET_INFO *cs
{
if ( r+2 > e )
return MY_CS_TOOSMALL2;
-
+
+ if (wc > 0xFFFF) /* UCS2 does not support characters outside BMP */
+ return MY_CS_ILUNI;
+
r[0]= (uchar) (wc >> 8);
r[1]= (uchar) (wc & 0xFF);
return 2;
Attachment: [text/bzr-bundle] bzr/bar@mysql.com-20101215095837-lkrt9d2srudod5b5.bundle
Thread |
---|
• bzr commit into mysql-5.5-bugteam branch (bar:3195) Bug#58321 | Alexander Barkov | 15 Dec |