1select @@collation_connection;
2
3#
4# MDEV-5180 Data type for WEIGHT_STRING is too short in some cases
5#
6CREATE TABLE t1 AS SELECT 'a' AS a;
7SHOW CREATE TABLE t1;
8CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1;
9SHOW CREATE TABLE t2;
10SELECT HEX(WEIGHT_STRING(a)) FROM t1;
11SELECT HEX(ws) FROM t2;
12DROP TABLE t2;
13DROP TABLE t1;
14
15CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a;
16SHOW CREATE TABLE t1;
17CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1;
18SHOW CREATE TABLE t2;
19SELECT HEX(WEIGHT_STRING(a)) FROM t1;
20SELECT HEX(ws) FROM t2;
21DROP TABLE t2;
22CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1;
23SHOW CREATE TABLE t2;
24SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1;
25SELECT HEX(ws) FROM t2;
26DROP TABLE t2;
27CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1;
28SHOW CREATE TABLE t2;
29SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
30SELECT HEX(ws) FROM t2;
31DROP TABLE t2;
32DROP TABLE t1;
33#
34# End of MDEV-5180
35#
36
37select hex(weight_string('a'));
38select hex(weight_string('A'));
39select hex(weight_string('abc'));
40select hex(weight_string('abc' as char(2)));
41select hex(weight_string('abc' as char(3)));
42select hex(weight_string('abc' as char(5)));
43
44# Read 2 characters from the source string (the last character is not used).
45select hex(weight_string('abc', 1, 2, 0xC0));
46select hex(weight_string('abc', 2, 2, 0xC0));
47select hex(weight_string('abc', 3, 2, 0xC0));
48select hex(weight_string('abc', 4, 2, 0xC0));
49select hex(weight_string('abc', 5, 2, 0xC0));
50select hex(weight_string('abc',25, 2, 0xC0));
51
52# Read 3 characters from the source string (the entire string is used).
53select hex(weight_string('abc', 1, 3, 0xC0));
54select hex(weight_string('abc', 2, 3, 0xC0));
55select hex(weight_string('abc', 3, 3, 0xC0));
56select hex(weight_string('abc', 4, 3, 0xC0));
57select hex(weight_string('abc', 5, 3, 0xC0));
58select hex(weight_string('abc',25, 3, 0xC0));
59
60# Read 4 characters from the source string (extra space is added)
61select hex(weight_string('abc', 1, 4, 0xC0));
62select hex(weight_string('abc', 2, 4, 0xC0));
63select hex(weight_string('abc', 3, 4, 0xC0));
64select hex(weight_string('abc', 4, 4, 0xC0));
65select hex(weight_string('abc', 5, 4, 0xC0));
66select hex(weight_string('abc',25, 4, 0xC0));
67