From 53df09a9a6a99b82e2a8869eb16737a78772b29e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 15:25:23 +0500 Subject: Bug#28875 Conversion between ASCII and LATIN1 charsets does not function (Regression, caused by a patch for the bug 22646). Problem: when result type of date_format() was changed from binary string to character string, mixing date_format() with a ascii column in CONCAT() stopped to work. Fix: - adding "repertoire" flag into DTCollation class, to mark items which can return only pure ASCII strings. - allow character set conversion from pure ASCII to other character sets. include/m_ctype.h: Defining new flags. Adding new function prototypes. mysql-test/r/ctype_ucs.result: Adding tests. mysql-test/r/ctype_utf8.result: Adding tests. mysql-test/r/func_time.result: Adding tests. mysql-test/t/ctype_ucs.test: Adding tests. mysql-test/t/ctype_utf8.test: Adding tests. mysql-test/t/func_time.test: Adding test. mysys/charset.c: Adding pure ASCII detection when loading a dynamic character set. sql/item.cc: - Moving detection of a Unicode superset into function. - Adding detection of a ASCII subset. - Adding creation of to-ASCII character set convertor when safe_charset_converter() failed and when the argument. repertoire is know to be pure ASCII. sql/item.h: - Adding "repertoire" member into DTCollation class. - Adding "repertoire" argument to constructors. - Adding new methods: set_repertoire_from_charset() set_repertoire_from_value() sql/item_func.cc: Adding "repertoire" argument. sql/item_strfunc.cc: Adding "repertoire" argument. sql/item_timefunc.cc: Initializing the result repertoire taking into account the "is_ascii" flag of the current locale. sql/sql_lex.cc: Detect 7bit strings, return in Lex->text_string_is_7bit. sql/sql_lex.h: Adding new member into LEX structure. Adding new member into Lex_input_stream sql/sql_string.cc: Allow simple copy from pure ASCII to a ASCII-based character set. sql/sql_yacc.yy: Depening on Lex->text_string_is_7bit and character set features, create Item_string with MY_REPERTOIRE_ASCII when it is possible. strings/conf_to_src.c: - Adding printing of the "MY_CS_PUREASCII" flag - Adding printing of copyright strings/ctype-extra.c: Recreating ctype-extra.c: ascii_general_ci and ascii_bin are now marked with MY_CS_PUREASCII flag. strings/ctype.c: Adding new functions. --- mysql-test/r/ctype_ucs.result | 26 ++++++++++++++++++++++++++ mysql-test/r/ctype_utf8.result | 36 ++++++++++++++++++++++++++++++++++++ mysql-test/r/func_time.result | 16 ++++++++++++++++ 3 files changed, 78 insertions(+) (limited to 'mysql-test/r') diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 960953b3c5e..350fc3f6bd6 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -865,4 +865,30 @@ blob 65535 65535 text 65535 65535 text 65535 32767 drop table t1; +create table t1 (a varchar(15) character set ascii not null, b int); +insert into t1 values ('a',1); +select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1; +concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) +aa +select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1; +concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) +ab +select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062); +a b +a 1 +select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062); +a b +select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation 'concat' +select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062); +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation '=' +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; End of 5.0 tests diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 216b5f393fb..3b20ded7361 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1639,6 +1639,42 @@ coercibility(col1) collation(col1) 0 utf8_swedish_ci drop view v1, v2; drop table t1; +set names utf8; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, N'x', N'y')) from t1; +concat(a, if(b>10, N'x', N'y')) +ay +select concat(a, if(b>10, N'æ', N'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8'x', _utf8'y')) from t1; +concat(a, if(b>10, _utf8'x', _utf8'y')) +ay +select concat(a, if(b>10, _utf8'æ', _utf8'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8 0x78, _utf8 0x79)) from t1; +concat(a, if(b>10, _utf8 0x78, _utf8 0x79)) +ay +select concat(a, if(b>10, _utf8 0xC3A6, _utf8 0xC3AF)) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1; +concat(a, if(b>10, 'x' 'x', 'y' 'y')) +ayy +select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; CREATE TABLE t1 ( colA int(11) NOT NULL, colB varchar(255) character set utf8 NOT NULL, diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 56ea72a8ee3..2207cd27243 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1246,3 +1246,19 @@ SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SE TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") 838:59:58 838:59:59 +set names latin1; +create table t1 (a varchar(15) character set ascii not null); +insert into t1 values ('070514-000000'); +select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1; +concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) +# +set names swe7; +select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (swe7_swedish_ci,COERCIBLE) for operation 'concat' +set names latin1; +set lc_time_names=fr_FR; +select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1; +ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'concat' +set lc_time_names=en_US; +drop table t1; +End of 5.0 tests -- cgit v1.2.1