drop table if exists t1; set names latin1; select hex(weight_string(0x010203)); hex(weight_string(0x010203)) 010203 select hex(weight_string('aa' as char(3))); hex(weight_string('aa' as char(3))) 414120 select hex(weight_string('a' as char(-1))); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1)))' at line 1 select hex(weight_string('a' as char(0))); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0)))' at line 1 select hex(weight_string('a' as char(1))); hex(weight_string('a' as char(1))) 41 select hex(weight_string('ab' as char(1))); hex(weight_string('ab' as char(1))) 41 select hex(weight_string('ab')); hex(weight_string('ab')) 4142 select hex(weight_string('aa' as binary(3))); hex(weight_string('aa' as binary(3))) 616100 select hex(weight_string(cast('aa' as binary(3)))); hex(weight_string(cast('aa' as binary(3)))) 616100 create table t1 charset latin1 select weight_string('test') as w; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `w` varbinary(4) DEFAULT NULL ) ENGINE=ENGINE DEFAULT CHARSET=latin1 drop table t1; create table t1 charset latin1 select weight_string(repeat('t',66000)) as w; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `w` longblob ) ENGINE=ENGINE DEFAULT CHARSET=latin1 drop table t1; select weight_string(NULL); weight_string(NULL) NULL select 1 as weight_string, 2 as reverse; weight_string reverse 1 2 select coercibility(weight_string('test')); coercibility(weight_string('test')) 4 select coercibility(weight_string('test' collate latin1_swedish_ci)); coercibility(weight_string('test' collate latin1_swedish_ci)) 0 create table t1 (s1 varchar(5)) charset latin1; insert into t1 values ('a'),(null); select hex(weight_string(s1)) from t1 order by s1; hex(weight_string(s1)) NULL 41 drop table t1; # # BUG#11898467 - SERVER CRASHES ON SELECT HEX(WEIGHT_STRING(STR AS [CHAR|BINARY](N))) IF N IS BIG # SELECT HEX(WEIGHT_STRING('ab' AS CHAR(1000000000000000000))); HEX(WEIGHT_STRING('ab' AS CHAR(1000000000000000000))) NULL Warnings: Warning 1301 Result of weight_string() was larger than max_allowed_packet (67108864) - truncated SELECT HEX(WEIGHT_STRING('ab' AS BINARY(1000000000000000000))); HEX(WEIGHT_STRING('ab' AS BINARY(1000000000000000000))) NULL Warnings: Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated # # BUG#21974321: WEIGHT_STRING RESULT IS WRONG IF USED IN A # VIEW (AS CHAR CLAUSE IS LOST) # SET NAMES utf8; Warnings: Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. SET collation_connection=utf16_unicode_ci; CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin2 COLLATE latin2_czech_cs); INSERT INTO t1 VALUES ('abcd'); INSERT INTO t1 VALUES ('dcba'); CREATE VIEW v1 AS SELECT WEIGHT_STRING(_latin1 'ab') AS b; CREATE VIEW v5 AS SELECT WEIGHT_STRING(a AS BINARY(2)) AS b FROM t1; CREATE VIEW v6 AS SELECT WEIGHT_STRING(a AS BINARY(6)) AS b FROM t1; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select weight_string(_latin1'ab') AS `b` utf8 utf16_unicode_ci SHOW CREATE VIEW v5; View Create View character_set_client collation_connection v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v5` AS select weight_string(cast(`t1`.`a` as char(2) charset binary)) AS `b` from `t1` utf8 utf16_unicode_ci SHOW CREATE VIEW v6; View Create View character_set_client collation_connection v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select weight_string(cast(`t1`.`a` as char(6) charset binary)) AS `b` from `t1` utf8 utf16_unicode_ci DROP VIEW v1; DROP VIEW v5; DROP VIEW v6; DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(10)) charset latin1; INSERT INTO t1 VALUES ('abcd'); INSERT INTO t1 VALUES ('dcba'); CREATE VIEW v1 AS SELECT WEIGHT_STRING(_latin1 'ab') AS b; CREATE VIEW v2 AS SELECT WEIGHT_STRING(a) AS b FROM t1; CREATE VIEW v3 AS SELECT WEIGHT_STRING(a AS CHAR(2)) AS b FROM t1; CREATE VIEW v4 AS SELECT WEIGHT_STRING(a AS CHAR(6)) AS b FROM t1; CREATE VIEW v5 AS SELECT WEIGHT_STRING(a AS BINARY(2)) AS b FROM t1; CREATE VIEW v6 AS SELECT WEIGHT_STRING(a AS BINARY(6)) AS b FROM t1; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select weight_string(_latin1'ab') AS `b` utf8 utf16_unicode_ci SHOW CREATE VIEW v2; View Create View character_set_client collation_connection v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select weight_string(`t1`.`a`) AS `b` from `t1` utf8 utf16_unicode_ci SHOW CREATE VIEW v3; View Create View character_set_client collation_connection v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select weight_string(`t1`.`a` as char(2)) AS `b` from `t1` utf8 utf16_unicode_ci SHOW CREATE VIEW v4; View Create View character_set_client collation_connection v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select weight_string(`t1`.`a` as char(6)) AS `b` from `t1` utf8 utf16_unicode_ci SHOW CREATE VIEW v5; View Create View character_set_client collation_connection v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v5` AS select weight_string(cast(`t1`.`a` as char(2) charset binary)) AS `b` from `t1` utf8 utf16_unicode_ci SHOW CREATE VIEW v6; View Create View character_set_client collation_connection v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select weight_string(cast(`t1`.`a` as char(6) charset binary)) AS `b` from `t1` utf8 utf16_unicode_ci SELECT HEX(b) FROM v1; HEX(b) 4142 SELECT HEX(WEIGHT_STRING(_latin1 'ab')); HEX(WEIGHT_STRING(_latin1 'ab')) 4142 SELECT HEX(b) FROM v2; HEX(b) 41424344 44434241 SELECT HEX(b) FROM v3; HEX(b) 4142 4443 SELECT HEX(b) FROM v4; HEX(b) 414243442020 444342412020 SELECT HEX(b) FROM v5; HEX(b) 6162 6463 Warnings: Warning 1292 Truncated incorrect BINARY(2) value: 'abcd' Warning 1292 Truncated incorrect BINARY(2) value: 'dcba' SELECT HEX(WEIGHT_STRING(a AS BINARY(2))) FROM t1; HEX(WEIGHT_STRING(a AS BINARY(2))) 6162 6463 Warnings: Warning 1292 Truncated incorrect BINARY(2) value: 'abcd' Warning 1292 Truncated incorrect BINARY(2) value: 'dcba' SELECT HEX(b) FROM v6; HEX(b) 616263640000 646362610000 SELECT HEX(WEIGHT_STRING(a AS BINARY(6))) FROM t1; HEX(WEIGHT_STRING(a AS BINARY(6))) 616263640000 646362610000 DROP VIEW v1; DROP VIEW v2; DROP VIEW v3; DROP VIEW v4; DROP VIEW v5; DROP VIEW v6; DROP TABLE t1; # # BUG#27752619: ASSERTION FAILED: SRC WEIGHT_STRING IN # MY_STRNXFRM_UNICODE_FULL_BIN # SELECT HEX(WEIGHT_STRING(JSON_UNQUOTE(JSON_SET('{}','$','')))); HEX(WEIGHT_STRING(JSON_UNQUOTE(JSON_SET('{}','$',''))))