diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2013-10-25 15:01:03 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2013-10-25 15:01:03 +0400 |
commit | 71f8ca654eceea835d6330eb511ce41643dfaeb5 (patch) | |
tree | 2e87ceb27347664cd9317b7ba24a6cbc0f47749a | |
parent | a6e28ce5e6a1cb2c5e4eaf9e900e7d6339094a75 (diff) | |
download | mariadb-git-71f8ca654eceea835d6330eb511ce41643dfaeb5.tar.gz |
MDEV-5180 Data type for WEIGHT_STRING is too short in some cases
(a bug in upstream)
32 files changed, 3325 insertions, 43 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h index 826f0b98488..b9682df12bf 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -188,6 +188,7 @@ extern MY_UNI_CTYPE my_uni_ctype[256]; #define MY_CS_NONASCII 8192 /* if not ASCII-compatible */ #define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */ #define MY_CS_LOWER_SORT 32768 /* If use lower case as weight */ +#define MY_CS_STRNXFRM_BAD_NWEIGHTS 0x10000 /* strnxfrm ignores "nweights" */ #define MY_CHARSET_UNDEFINED 0 /* Character repertoire flags */ @@ -672,6 +673,7 @@ size_t my_strnxfrm_mb(CHARSET_INFO *, size_t my_strnxfrm_unicode(CHARSET_INFO *, uchar *dst, size_t dstlen, uint nweights, const uchar *src, size_t srclen, uint flags); +size_t my_strnxfrmlen_unicode(CHARSET_INFO *, size_t); size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *, uchar *dst, size_t dstlen, uint nweights, diff --git a/mysql-test/include/weight_string.inc b/mysql-test/include/weight_string.inc index d8621a19687..1ae8801c560 100644 --- a/mysql-test/include/weight_string.inc +++ b/mysql-test/include/weight_string.inc @@ -1,4 +1,39 @@ select @@collation_connection; + +# +# MDEV-5180 Data type for WEIGHT_STRING is too short in some cases +# +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +SELECT HEX(ws) FROM t2; +DROP TABLE t2; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +SELECT HEX(ws) FROM t2; +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +SELECT HEX(ws) FROM t2; +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +SELECT HEX(ws) FROM t2; +DROP TABLE t2; +DROP TABLE t1; +# +# End of MDEV-5180 +# + select hex(weight_string('a')); select hex(weight_string('A')); select hex(weight_string('abc')); diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 18abda2a2d7..da0f64fa4ee 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -565,6 +565,72 @@ set names big5; select @@collation_connection; @@collation_connection big5_chinese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET big5 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET big5 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -758,6 +824,72 @@ set collation_connection=big5_bin; select @@collation_connection; @@collation_connection big5_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET big5 COLLATE big5_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET big5 COLLATE big5_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result index 41cf6dca358..0e6b9a7653f 100644 --- a/mysql-test/r/ctype_cp1250_ch.result +++ b/mysql-test/r/ctype_cp1250_ch.result @@ -255,6 +255,72 @@ set names cp1250 collate cp1250_czech_cs; select @@collation_connection; @@collation_connection cp1250_czech_cs +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +A402 +SELECT HEX(ws) FROM t2; +HEX(ws) +A402 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET cp1250 COLLATE cp1250_czech_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +A4A4A4A4A40202020202 +SELECT HEX(ws) FROM t2; +HEX(ws) +A4A4A4A4A40202020202 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +A4A4A4A4A40202020202 +SELECT HEX(ws) FROM t2; +HEX(ws) +A4A4A4A4A40202020202 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +A4A4A4A4A40202020202 +SELECT HEX(ws) FROM t2; +HEX(ws) +A4A4A4A4A40202020202 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) A402 diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index 69d05b1c946..37631f9f4bb 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -19543,6 +19543,72 @@ set names cp932; select @@collation_connection; @@collation_connection cp932_japanese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET cp932 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET cp932 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -19736,6 +19802,72 @@ set collation_connection=cp932_bin; select @@collation_connection; @@collation_connection cp932_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET cp932 COLLATE cp932_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET cp932 COLLATE cp932_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result index e171e4a6352..70cebf3f80d 100644 --- a/mysql-test/r/ctype_eucjpms.result +++ b/mysql-test/r/ctype_eucjpms.result @@ -32621,6 +32621,72 @@ set names eucjpms; select @@collation_connection; @@collation_connection eucjpms_japanese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET eucjpms NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET eucjpms NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -32988,6 +33054,72 @@ set collation_connection=eucjpms_bin; select @@collation_connection; @@collation_connection eucjpms_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET eucjpms COLLATE eucjpms_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET eucjpms COLLATE eucjpms_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index 6299b3e38fd..4b395359373 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -24612,6 +24612,72 @@ set names euckr; select @@collation_connection; @@collation_connection euckr_korean_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET euckr NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET euckr NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -24805,6 +24871,72 @@ set collation_connection=euckr_bin; select @@collation_connection; @@collation_connection euckr_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET euckr COLLATE euckr_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET euckr COLLATE euckr_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index d947674909b..ac482bcab1d 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -558,6 +558,72 @@ set names gb2312; select @@collation_connection; @@collation_connection gb2312_chinese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET gb2312 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET gb2312 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -751,6 +817,72 @@ set collation_connection=gb2312_bin; select @@collation_connection; @@collation_connection gb2312_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET gb2312 COLLATE gb2312_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET gb2312 COLLATE gb2312_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index ec5fe0578cf..1578c899682 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -590,6 +590,72 @@ set names gbk; select @@collation_connection; @@collation_connection gbk_chinese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET gbk NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET gbk NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -957,6 +1023,72 @@ set collation_connection=gbk_bin; select @@collation_connection; @@collation_connection gbk_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET gbk COLLATE gbk_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET gbk COLLATE gbk_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 5cdce537241..a1a48130454 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -3342,6 +3342,72 @@ set @@collation_connection=latin1_swedish_ci; select @@collation_connection; @@collation_connection latin1_swedish_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -3520,6 +3586,72 @@ set @@collation_connection=latin1_bin; select @@collation_connection; @@collation_connection latin1_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 @@ -3698,6 +3830,72 @@ set @@collation_connection=latin1_general_cs; select @@collation_connection; @@collation_connection latin1_general_cs +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +42 +SELECT HEX(ws) FROM t2; +HEX(ws) +42 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4242424242 +SELECT HEX(ws) FROM t2; +HEX(ws) +4242424242 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +424242 +SELECT HEX(ws) FROM t2; +HEX(ws) +424242 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +42424242422020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +42424242422020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 42 @@ -3876,6 +4074,72 @@ set @@collation_connection=binary; select @@collation_connection; @@collation_connection binary +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(5) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161610000000000 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161610000000000 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index d69102e76ff..0f115623ede 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -415,6 +415,72 @@ set @@collation_connection=latin1_german2_ci; select @@collation_connection; @@collation_connection latin1_german2_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) COLLATE latin1_german2_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) COLLATE latin1_german2_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 diff --git a/mysql-test/r/ctype_latin2.result b/mysql-test/r/ctype_latin2.result index 2ddb78d5cc8..84853db288a 100644 --- a/mysql-test/r/ctype_latin2.result +++ b/mysql-test/r/ctype_latin2.result @@ -392,6 +392,72 @@ set names latin2; select @@collation_connection; @@collation_connection latin2_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET latin2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -498,6 +564,72 @@ set collation_connection=latin2_bin; select @@collation_connection; @@collation_connection latin2_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET latin2 COLLATE latin2_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET latin2 COLLATE latin2_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_latin2_ch.result b/mysql-test/r/ctype_latin2_ch.result index ebe01fdb747..4d4c1cae675 100644 --- a/mysql-test/r/ctype_latin2_ch.result +++ b/mysql-test/r/ctype_latin2_ch.result @@ -58,6 +58,72 @@ strcmp('a\t','a ') select @@collation_connection; @@collation_connection latin2_czech_cs +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET latin2 COLLATE latin2_czech_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(8) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0301030103010300 +SELECT HEX(ws) FROM t2; +HEX(ws) +0301030103010300 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET latin2 COLLATE latin2_czech_cs NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(24) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +030303030301030303030301030303030301030303030300 +SELECT HEX(ws) FROM t2; +HEX(ws) +030303030301030303030301030303030301030303030300 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(24) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +030303030301030303030301030303030301030303030300 +SELECT HEX(ws) FROM t2; +HEX(ws) +030303030301030303030301030303030301030303030300 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(24) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +030303030301030303030301030303030301030303030300 +SELECT HEX(ws) FROM t2; +HEX(ws) +030303030301030303030301030303030301030303030300 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0301030103010300 diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index 110d81491f9..5dcc25123b3 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -14572,6 +14572,72 @@ set names sjis; select @@collation_connection; @@collation_connection sjis_japanese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET sjis NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET sjis NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -14765,6 +14831,72 @@ set collation_connection=sjis_bin; select @@collation_connection; @@collation_connection sjis_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET sjis COLLATE sjis_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET sjis COLLATE sjis_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result index a338d05a8e8..5b2858ad999 100644 --- a/mysql-test/r/ctype_tis620.result +++ b/mysql-test/r/ctype_tis620.result @@ -3004,6 +3004,72 @@ set collation_connection=tis620_thai_ci; select @@collation_connection; @@collation_connection tis620_thai_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET tis620 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET tis620 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(40) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 @@ -3116,6 +3182,72 @@ set collation_connection=tis620_bin; select @@collation_connection; @@collation_connection tis620_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET tis620 COLLATE tis620_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET tis620 COLLATE tis620_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(5) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index afcf87d62e8..4a7bb3b75c9 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -3333,6 +3333,72 @@ set collation_connection=ucs2_unicode_ci; select @@collation_connection; @@collation_connection ucs2_unicode_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E33 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(80) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E330E330E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(48) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +0E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(160) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0E330E330E330E330E3302090209020902090209 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E3302090209020902090209 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0E33 @@ -3511,6 +3577,72 @@ set @@collation_connection=utf8_unicode_ci; select @@collation_connection; @@collation_connection utf8_unicode_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E33 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(80) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E330E330E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(48) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +0E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(160) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0E330E330E330E330E3302090209020902090209 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E3302090209020902090209 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0E33 diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 85b3ae6c8dd..34e20905ae6 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -4273,6 +4273,72 @@ set collation_connection=ucs2_general_ci; select @@collation_connection; @@collation_connection ucs2_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0041 @@ -4451,6 +4517,72 @@ set collation_connection=ucs2_bin; select @@collation_connection; @@collation_connection ucs2_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0061 +SELECT HEX(ws) FROM t2; +HEX(ws) +0061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00610061006100610061 +SELECT HEX(ws) FROM t2; +HEX(ws) +00610061006100610061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +006100610061 +SELECT HEX(ws) FROM t2; +HEX(ws) +006100610061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0061006100610061006100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0061006100610061006100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0061 diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index f167f5d1446..e5747e7ee76 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -24926,6 +24926,72 @@ set names ujis; select @@collation_connection; @@collation_connection ujis_japanese_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET ujis NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +41 +SELECT HEX(ws) FROM t2; +HEX(ws) +41 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET ujis NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +4141414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +4141414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +414141 +SELECT HEX(ws) FROM t2; +HEX(ws) +414141 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +41414141412020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +41414141412020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 41 @@ -25293,6 +25359,72 @@ set collation_connection=ujis_bin; select @@collation_connection; @@collation_connection ujis_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET ujis COLLATE ujis_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +61 +SELECT HEX(ws) FROM t2; +HEX(ws) +61 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET ujis COLLATE ujis_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +6161616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +6161616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +616161 +SELECT HEX(ws) FROM t2; +HEX(ws) +616161 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +61616161612020202020 +SELECT HEX(ws) FROM t2; +HEX(ws) +61616161612020202020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 61 diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result index 1b2bd4b62cf..0c00ea46d09 100644 --- a/mysql-test/r/ctype_utf16.result +++ b/mysql-test/r/ctype_utf16.result @@ -1337,6 +1337,72 @@ set collation_connection=utf16_general_ci; select @@collation_connection; @@collation_connection utf16_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf16 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0041 @@ -1521,6 +1587,72 @@ set collation_connection=utf16_bin; select @@collation_connection; @@collation_connection utf16_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061000061000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +000061000061000061000061000061000020000020000020000020000020 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061000020000020000020000020000020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 000061 diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result index c33b27d5317..6b27f88ee17 100644 --- a/mysql-test/r/ctype_utf16_uca.result +++ b/mysql-test/r/ctype_utf16_uca.result @@ -2487,6 +2487,72 @@ set collation_connection=utf16_unicode_ci; select @@collation_connection; @@collation_connection utf16_unicode_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E33 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(80) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E330E330E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(48) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +0E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(160) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0E330E330E330E330E3302090209020902090209 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E3302090209020902090209 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0E33 diff --git a/mysql-test/r/ctype_utf16le.result b/mysql-test/r/ctype_utf16le.result index a8407001ce2..a2ac921af0c 100644 --- a/mysql-test/r/ctype_utf16le.result +++ b/mysql-test/r/ctype_utf16le.result @@ -1578,6 +1578,72 @@ SET NAMES utf8, collation_connection=utf16le_general_ci; select @@collation_connection; @@collation_connection utf16le_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16le NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf16le NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0041 @@ -1762,6 +1828,72 @@ SET NAMES utf8, collation_connection=utf16le_bin; select @@collation_connection; @@collation_connection utf16le_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf16le COLLATE utf16le_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf16le COLLATE utf16le_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061000061000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +000061000061000061000061000061000020000020000020000020000020 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061000020000020000020000020000020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 000061 diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result index 4cdbdea1fc3..d1c65749b99 100644 --- a/mysql-test/r/ctype_utf32.result +++ b/mysql-test/r/ctype_utf32.result @@ -1390,6 +1390,72 @@ set collation_connection=utf32_general_ci; select @@collation_connection; @@collation_connection utf32_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf32 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf32 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0041 @@ -1574,6 +1640,72 @@ set collation_connection=utf32_bin; select @@collation_connection; @@collation_connection utf32_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061000061000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +000061000061000061000061000061000020000020000020000020000020 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061000020000020000020000020000020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 000061 diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result index 1c8b683f4fa..7e8587c7ea3 100644 --- a/mysql-test/r/ctype_utf32_uca.result +++ b/mysql-test/r/ctype_utf32_uca.result @@ -2507,6 +2507,72 @@ set collation_connection=utf32_unicode_ci; select @@collation_connection; @@collation_connection utf32_unicode_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E33 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(80) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0E330E330E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(48) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +0E330E330E33 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E33 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(160) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0E330E330E330E330E3302090209020902090209 +SELECT HEX(ws) FROM t2; +HEX(ws) +0E330E330E330E330E3302090209020902090209 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0E33 diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index ccc379b1864..9356747ffa3 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -5139,6 +5139,72 @@ set names utf8; select @@collation_connection; @@collation_connection utf8_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0041 @@ -5317,6 +5383,72 @@ set @@collation_connection=utf8_bin; select @@collation_connection; @@collation_connection utf8_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0061 +SELECT HEX(ws) FROM t2; +HEX(ws) +0061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00610061006100610061 +SELECT HEX(ws) FROM t2; +HEX(ws) +00610061006100610061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +006100610061 +SELECT HEX(ws) FROM t2; +HEX(ws) +006100610061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0061006100610061006100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0061006100610061006100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; select hex(weight_string('a')); hex(weight_string('a')) 0061 diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index ecd4b8bcef5..72c3066b0cd 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2583,5 +2583,499 @@ DROP TABLE t1; # End of 5.5 tests # # +# WL#3664 WEIGHT_STRING +# +set names utf8mb4; +select @@collation_connection; +@@collation_connection +utf8mb4_general_ci +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +0041 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +00410041004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +00410041004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +004100410041 +SELECT HEX(ws) FROM t2; +HEX(ws) +004100410041 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +0041004100410041004100200020002000200020 +SELECT HEX(ws) FROM t2; +HEX(ws) +0041004100410041004100200020002000200020 +DROP TABLE t2; +DROP TABLE t1; +select hex(weight_string('a')); +hex(weight_string('a')) +0041 +select hex(weight_string('A')); +hex(weight_string('A')) +0041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +004100420043 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +00410042 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +004100420043 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +00410042004300200020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0041 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +004100 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00410042002000200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0041 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +004100 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00410042004300200020002000200020002000200020002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0041 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +004100 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00410042 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0041004200 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00410042004300200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +utf8mb4_general_ci +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +20AC20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +20AC20AC20AC00200020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +20AC20AC00 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +20AC20AC002000200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +20 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +20AC20AC +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +20AC20AC20 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +20AC20AC20AC00200020002000200020002000200020002000 +select @@collation_connection; +@@collation_connection +utf8mb4_general_ci +select hex(weight_string('a' LEVEL 1)); +hex(weight_string('a' LEVEL 1)) +0041 +select hex(weight_string('A' LEVEL 1)); +hex(weight_string('A' LEVEL 1)) +0041 +select hex(weight_string('abc' LEVEL 1)); +hex(weight_string('abc' LEVEL 1)) +004100420043 +select hex(weight_string('abc' as char(2) LEVEL 1)); +hex(weight_string('abc' as char(2) LEVEL 1)) +00410042 +select hex(weight_string('abc' as char(3) LEVEL 1)); +hex(weight_string('abc' as char(3) LEVEL 1)) +004100420043 +select hex(weight_string('abc' as char(5) LEVEL 1)); +hex(weight_string('abc' as char(5) LEVEL 1)) +00410042004300200020 +select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE)); +hex(weight_string('abc' as char(5) LEVEL 1 REVERSE)) +20002000430042004100 +select hex(weight_string('abc' as char(5) LEVEL 1 DESC)); +hex(weight_string('abc' as char(5) LEVEL 1 DESC)) +FFBEFFBDFFBCFFDFFFDF +select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE)); +hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE)) +DFFFDFFFBCFFBDFFBEFF +set @@collation_connection=utf8mb4_bin; +select @@collation_connection; +@@collation_connection +utf8mb4_bin +CREATE TABLE t1 AS SELECT 'a' AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(15) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a)) FROM t1; +HEX(WEIGHT_STRING(a)) +000061000061000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(3))) +000061000061000061 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061 +DROP TABLE t2; +CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ws` varbinary(30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1; +HEX(WEIGHT_STRING(a AS CHAR(10))) +000061000061000061000061000061000020000020000020000020000020 +SELECT HEX(ws) FROM t2; +HEX(ws) +000061000061000061000061000061000020000020000020000020000020 +DROP TABLE t2; +DROP TABLE t1; +select hex(weight_string('a')); +hex(weight_string('a')) +000061 +select hex(weight_string('A')); +hex(weight_string('A')) +000041 +select hex(weight_string('abc')); +hex(weight_string('abc')) +000061000062000063 +select hex(weight_string('abc' as char(2))); +hex(weight_string('abc' as char(2))) +000061000062 +select hex(weight_string('abc' as char(3))); +hex(weight_string('abc' as char(3))) +000061000062000063 +select hex(weight_string('abc' as char(5))); +hex(weight_string('abc' as char(5))) +000061000062000063000020000020 +select hex(weight_string('abc', 1, 2, 0xC0)); +hex(weight_string('abc', 1, 2, 0xC0)) +00 +select hex(weight_string('abc', 2, 2, 0xC0)); +hex(weight_string('abc', 2, 2, 0xC0)) +0000 +select hex(weight_string('abc', 3, 2, 0xC0)); +hex(weight_string('abc', 3, 2, 0xC0)) +000061 +select hex(weight_string('abc', 4, 2, 0xC0)); +hex(weight_string('abc', 4, 2, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 2, 0xC0)); +hex(weight_string('abc', 5, 2, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 2, 0xC0)); +hex(weight_string('abc',25, 2, 0xC0)) +00006100006200002000002000002000002000002000002000 +select hex(weight_string('abc', 1, 3, 0xC0)); +hex(weight_string('abc', 1, 3, 0xC0)) +00 +select hex(weight_string('abc', 2, 3, 0xC0)); +hex(weight_string('abc', 2, 3, 0xC0)) +0000 +select hex(weight_string('abc', 3, 3, 0xC0)); +hex(weight_string('abc', 3, 3, 0xC0)) +000061 +select hex(weight_string('abc', 4, 3, 0xC0)); +hex(weight_string('abc', 4, 3, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 3, 0xC0)); +hex(weight_string('abc', 5, 3, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 3, 0xC0)); +hex(weight_string('abc',25, 3, 0xC0)) +00006100006200006300002000002000002000002000002000 +select hex(weight_string('abc', 1, 4, 0xC0)); +hex(weight_string('abc', 1, 4, 0xC0)) +00 +select hex(weight_string('abc', 2, 4, 0xC0)); +hex(weight_string('abc', 2, 4, 0xC0)) +0000 +select hex(weight_string('abc', 3, 4, 0xC0)); +hex(weight_string('abc', 3, 4, 0xC0)) +000061 +select hex(weight_string('abc', 4, 4, 0xC0)); +hex(weight_string('abc', 4, 4, 0xC0)) +00006100 +select hex(weight_string('abc', 5, 4, 0xC0)); +hex(weight_string('abc', 5, 4, 0xC0)) +0000610000 +select hex(weight_string('abc',25, 4, 0xC0)); +hex(weight_string('abc',25, 4, 0xC0)) +00006100006200006300002000002000002000002000002000 +select @@collation_connection; +@@collation_connection +utf8mb4_bin +select hex(weight_string(cast(_latin1 0x80 as char))); +hex(weight_string(cast(_latin1 0x80 as char))) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char))); +hex(weight_string(cast(_latin1 0x808080 as char))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(2))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(2))) +0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(3))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(3))) +0020AC0020AC0020AC +select hex(weight_string(cast(_latin1 0x808080 as char) as char(5))); +hex(weight_string(cast(_latin1 0x808080 as char) as char(5))) +0020AC0020AC0020AC000020000020 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0)) +0020AC0020AC00002000002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0)) +00 +select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0)) +0020 +select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0)) +0020AC +select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0)) +0020AC00 +select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0)) +0020AC0020 +select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)); +hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0)) +0020AC0020AC0020AC00002000002000002000002000002000 +select @@collation_connection; +@@collation_connection +utf8mb4_bin +select hex(weight_string('a' LEVEL 1)); +hex(weight_string('a' LEVEL 1)) +000061 +select hex(weight_string('A' LEVEL 1)); +hex(weight_string('A' LEVEL 1)) +000041 +select hex(weight_string('abc' LEVEL 1)); +hex(weight_string('abc' LEVEL 1)) +000061000062000063 +select hex(weight_string('abc' as char(2) LEVEL 1)); +hex(weight_string('abc' as char(2) LEVEL 1)) +000061000062 +select hex(weight_string('abc' as char(3) LEVEL 1)); +hex(weight_string('abc' as char(3) LEVEL 1)) +000061000062000063 +select hex(weight_string('abc' as char(5) LEVEL 1)); +hex(weight_string('abc' as char(5) LEVEL 1)) +000061000062000063000020000020 +select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE)); +hex(weight_string('abc' as char(5) LEVEL 1 REVERSE)) +200000200000630000620000610000 +select hex(weight_string('abc' as char(5) LEVEL 1 DESC)); +hex(weight_string('abc' as char(5) LEVEL 1 DESC)) +FFFF9EFFFF9DFFFF9CFFFFDFFFFFDF +select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE)); +hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE)) +DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF +# +# End of 5.6 tests +# +# # End of tests # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index e5ede872075..934adb50cca 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1829,6 +1829,26 @@ DROP TABLE t1; --echo # End of 5.5 tests --echo # + +--echo # +--echo # WL#3664 WEIGHT_STRING +--echo # + +set names utf8mb4; +--source include/weight_string.inc +--source include/weight_string_euro.inc +--source include/weight_string_l1.inc + +set @@collation_connection=utf8mb4_bin; +--source include/weight_string.inc +--source include/weight_string_euro.inc +--source include/weight_string_l1.inc + +--echo # +--echo # End of 5.6 tests +--echo # + + --echo # --echo # End of tests --echo # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 68009d6ba84..ec1c795c100 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3546,9 +3546,14 @@ void Item_func_weight_string::fix_length_and_dec() Use result_length if it was given explicitly in constructor, otherwise calculate max_length using argument's max_length and "nweights". - */ - max_length= result_length ? result_length : - cs->mbmaxlen * MY_MAX(args[0]->max_length, nweights); + */ + if (!(max_length= result_length)) + { + uint char_length; + char_length= ((cs->state & MY_CS_STRNXFRM_BAD_NWEIGHTS) || !nweights) ? + args[0]->max_char_length() : nweights; + max_length= cs->coll->strnxfrmlen(cs, char_length * cs->mbmaxlen); + } maybe_null= 1; } @@ -3570,9 +3575,35 @@ String *Item_func_weight_string::val_str(String *str) explicitly, otherwise calculate result length from argument and "nweights". */ - tmp_length= result_length ? result_length : - cs->coll->strnxfrmlen(cs, cs->mbmaxlen * - MY_MAX(res->length(), nweights)); + if (!(tmp_length= result_length)) + { + uint char_length; + if (cs->state & MY_CS_STRNXFRM_BAD_NWEIGHTS) + { + /* + latin2_czech_cs and cp1250_czech_cs do not support + the "nweights" limit in strnxfrm(). Use the full length. + */ + char_length= res->length(); + } + else + { + /* + If we don't need to pad the result with spaces, then it should be + OK to calculate character length of the argument approximately: + "res->length() / cs->mbminlen" can return a number that is + bigger than the real number of characters in the string, so + we'll allocate a little bit more memory but avoid calling + the slow res->numchars(). + In case if we do need to pad with spaces, we call res->numchars() + to know the true number of characters. + */ + if (!(char_length= nweights)) + char_length= (flags & MY_STRXFRM_PAD_WITH_SPACE) ? + res->numchars() : (res->length() / cs->mbminlen); + } + tmp_length= cs->coll->strnxfrmlen(cs, char_length * cs->mbmaxlen); + } if(tmp_length > current_thd->variables.max_allowed_packet) { diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 4698521bd16..6603bc7d3e5 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -625,7 +625,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = struct charset_info_st my_charset_latin2_czech_ci = { 2,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT|MY_CS_STRNXFRM_BAD_NWEIGHTS, /* state */ "latin2", /* cs name */ "latin2_czech_cs", /* name */ "", /* comment */ diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 6eb68385832..7ed88da1ffa 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -9484,6 +9484,12 @@ static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs, dst, dstlen, nweights, src, srclen, flags); } +static size_t my_strnxfrmlen_any_uca(CHARSET_INFO *cs, size_t len) +{ + /* UCA uses 2 bytes per weight */ + return (len + cs->mbmaxlen - 1) / cs->mbmaxlen * cs->strxfrm_multiply * 2; +} + #ifdef HAVE_CHARSET_ucs2 /* @@ -9529,7 +9535,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = my_strnncoll_ucs2_uca, my_strnncollsp_ucs2_uca, my_strnxfrm_ucs2_uca, - my_strnxfrmlen_simple, + my_strnxfrmlen_any_uca, my_like_range_generic, my_wildcmp_uca, NULL, @@ -10260,7 +10266,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, - my_strnxfrmlen_simple, + my_strnxfrmlen_any_uca, my_like_range_mb, my_wildcmp_uca, NULL, @@ -11733,7 +11739,7 @@ MY_COLLATION_HANDLER my_collation_utf32_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, - my_strnxfrmlen_simple, + my_strnxfrmlen_any_uca, my_like_range_generic, my_wildcmp_uca, NULL, @@ -12464,7 +12470,7 @@ MY_COLLATION_HANDLER my_collation_utf16_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, - my_strnxfrmlen_simple, + my_strnxfrmlen_any_uca, my_like_range_generic, my_wildcmp_uca, NULL, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 344039013f3..8a5e92fd6ce 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1626,7 +1626,7 @@ static MY_COLLATION_HANDLER my_collation_utf16_general_ci_handler = my_strnncoll_utf16, my_strnncollsp_utf16, my_strnxfrm_unicode, - my_strnxfrmlen_simple, + my_strnxfrmlen_unicode, my_like_range_generic, my_wildcmp_utf16_ci, my_strcasecmp_mb2_or_mb4, @@ -2200,13 +2200,6 @@ my_strnncollsp_utf32(CHARSET_INFO *cs, } -static size_t -my_strnxfrmlen_utf32(CHARSET_INFO *cs __attribute__((unused)), size_t len) -{ - return len / 2; -} - - static uint my_ismbchar_utf32(CHARSET_INFO *cs __attribute__((unused)), const char *b __attribute__((unused)), @@ -2721,7 +2714,7 @@ static MY_COLLATION_HANDLER my_collation_utf32_general_ci_handler = my_strnncoll_utf32, my_strnncollsp_utf32, my_strnxfrm_unicode, - my_strnxfrmlen_utf32, + my_strnxfrmlen_unicode, my_like_range_generic, my_wildcmp_utf32_ci, my_strcasecmp_mb2_or_mb4, @@ -3340,7 +3333,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = my_strnncoll_ucs2, my_strnncollsp_ucs2, my_strnxfrm_unicode, - my_strnxfrmlen_simple, + my_strnxfrmlen_unicode, my_like_range_generic, my_wildcmp_ucs2_ci, my_strcasecmp_mb2_or_mb4, @@ -3356,7 +3349,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_strnncoll_ucs2_bin, my_strnncollsp_ucs2_bin, my_strnxfrm_unicode, - my_strnxfrmlen_simple, + my_strnxfrmlen_unicode, my_like_range_generic, my_wildcmp_ucs2_bin, my_strcasecmp_mb2_or_mb4, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 207eaffb1a3..4cd05fcb591 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2219,6 +2219,16 @@ my_strnxfrm_unicode(CHARSET_INFO *cs, /* + For BMP-only collations that use 2 bytes per weight. +*/ +size_t +my_strnxfrmlen_unicode(CHARSET_INFO *cs, size_t len) +{ + + return ((len + cs->mbmaxlen - 1) / cs->mbmaxlen) * 2; +} + +/* Store sorting weights using 3 bytes per character. This function is shared between utf8mb4_bin, utf16_bin, utf32_bin. */ @@ -2989,13 +2999,6 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, } -static -size_t my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), - size_t len) -{ - return (len * 2 + 2) / 3; -} - static uint my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) { my_wc_t wc; @@ -3032,7 +3035,7 @@ static MY_COLLATION_HANDLER my_collation_utf8_general_ci_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, @@ -3048,7 +3051,7 @@ static MY_COLLATION_HANDLER my_collation_utf8_bin_handler = my_strnncoll_mb_bin, my_strnncollsp_mb_bin, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, @@ -3328,7 +3331,7 @@ static MY_COLLATION_HANDLER my_collation_cs_handler = my_strnncoll_utf8_cs, my_strnncollsp_utf8_cs, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_simple, my_wildcmp_mb, my_strcasecmp_utf8, @@ -4601,7 +4604,7 @@ static MY_COLLATION_HANDLER my_collation_filename_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, @@ -5428,14 +5431,6 @@ my_wildcmp_utf8mb4(CHARSET_INFO *cs, } -static size_t -my_strnxfrmlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), size_t len) -{ - /* TODO: fix when working on WL "Unicode new version" */ - return (len * 2 + 2) / 4; -} - - static uint my_ismbchar_utf8mb4(CHARSET_INFO *cs, const char *b, const char *e) { @@ -5468,7 +5463,7 @@ static MY_COLLATION_HANDLER my_collation_utf8mb4_general_ci_handler= my_strnncoll_utf8mb4, my_strnncollsp_utf8mb4, my_strnxfrm_unicode, - my_strnxfrmlen_utf8mb4, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8mb4, my_strcasecmp_utf8mb4, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index a688373f48e..20449788584 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -691,7 +691,7 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler = struct charset_info_st my_charset_cp1250_czech_ci = { 34,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT|MY_CS_STRNXFRM_BAD_NWEIGHTS, /* state */ "cp1250", /* cs name */ "cp1250_czech_cs", /* name */ "", /* comment */ |