drop table if exists t1;
SET @test_character_set= 'gb2312';
SET @test_collation= 'gb2312_chinese_ci';
SET @safe_character_set_server= @@character_set_server;
SET @safe_collation_server= @@collation_server;
SET @safe_character_set_client= @@character_set_client;
SET @safe_character_set_results= @@character_set_results;
SET character_set_server= @test_character_set;
SET collation_server= @test_collation;
CREATE DATABASE d1;
USE d1;
CREATE TABLE t1 (c CHAR(10), KEY(c));
SHOW FULL COLUMNS FROM t1;
Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
c	char(10)	gb2312_chinese_ci	YES	MUL	NULL			
INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa');
SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%';
want3results
aaa
aaaa
aaaaa
DROP TABLE t1;
CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2)));
SHOW FULL COLUMNS FROM t1;
Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
c1	varchar(15)	gb2312_chinese_ci	YES	MUL	NULL			
INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab');
SELECT c1 as want3results from t1 where c1 like 'l%';
want3results
location
loberge
lotre
SELECT c1 as want3results from t1 where c1 like 'lo%';
want3results
location
loberge
lotre
SELECT c1 as want1result  from t1 where c1 like 'loc%';
want1result
location
SELECT c1 as want1result  from t1 where c1 like 'loca%';
want1result
location
SELECT c1 as want1result  from t1 where c1 like 'locat%';
want1result
location
SELECT c1 as want1result  from t1 where c1 like 'locati%';
want1result
location
SELECT c1 as want1result  from t1 where c1 like 'locatio%';
want1result
location
SELECT c1 as want1result  from t1 where c1 like 'location%';
want1result
location
DROP TABLE t1;
create table t1 (a set('a') not null);
insert into t1 values (),();
Warnings:
Warning	1364	Field 'a' doesn't have a default value
select cast(a as char(1)) from t1;
cast(a as char(1))


select a sounds like a from t1;
a sounds like a
1
1
select 1 from t1 order by cast(a as char(1));
1
1
1
drop table t1;
set names utf8;
create table t1 (
name varchar(10),
level smallint unsigned);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `name` varchar(10) DEFAULT NULL,
  `level` smallint(5) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=gb2312
insert into t1 values ('string',1);
select concat(name,space(level)), concat(name, repeat(' ',level)) from t1;
concat(name,space(level))	concat(name, repeat(' ',level))
string 	string 
drop table t1;
DROP DATABASE d1;
USE test;
SET character_set_server= @safe_character_set_server;
SET collation_server= @safe_collation_server;
SET character_set_client= @safe_character_set_client;
SET character_set_results= @safe_character_set_results;
SET NAMES gb2312;
SET collation_connection='gb2312_chinese_ci';
create table t1 select repeat('a',4000) a;
delete from t1;
insert into t1 values ('a'), ('a '), ('a\t');
select collation(a),hex(a) from t1 order by a;
collation(a)	hex(a)
gb2312_chinese_ci	6109
gb2312_chinese_ci	61
gb2312_chinese_ci	6120
drop table t1;
#
# MDEV-5453 Assertion `src' fails in my_strnxfrm_unicode on GROUP BY MID(..) WITH ROLLUP
#
SELECT @@collation_connection;
@@collation_connection
gb2312_chinese_ci
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 GROUP BY MID(CURRENT_USER,0) WITH ROLLUP;
i
1
1
SELECT * FROM t1 GROUP BY MID('test',0) WITH ROLLUP;
i
1
1
DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
select collation(c1) from t1 limit 1;
collation(c1)
gb2312_chinese_ci
select c1 from t1 where c1 like 'abcdef%' order by c1;
c1
abcdefg
select c1 from t1 where c1 like 'abcde1%' order by c1;
c1
abcde100
abcde110
abcde111
select c1 from t1 where c1 like 'abcde11%' order by c1;
c1
abcde110
abcde111
select c1 from t1 where c1 like 'abcde111%' order by c1;
c1
abcde111
drop table t1;
select @@collation_connection;
@@collation_connection
gb2312_chinese_ci
create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
insert into t1 values('abcdef');
insert into t1 values('_bcdef');
insert into t1 values('a_cdef');
insert into t1 values('ab_def');
insert into t1 values('abc_ef');
insert into t1 values('abcd_f');
insert into t1 values('abcde_');
select c1 as c1u from t1 where c1 like 'ab\_def';
c1u
ab_def
select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5));
INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10));
INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11));
INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12));
SELECT hex(concat(repeat(0xF1F2, 10), '%'));
hex(concat(repeat(0xF1F2, 10), '%'))
F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225
3 rows expected
SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%');
a	hex(b)	c
2	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
3	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
4	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
DROP TABLE t1;
drop table if exists t1;
create table t1 select repeat('a',10) as c1;
delete from t1;
insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '')	GROUP_CONCAT(hex(c1) ORDER BY BINARY c1)
 	20
!	21
"	22
#	23
$	24
%	25
&	26
'	27
(	28
)	29
*	2A
+	2B
,	2C
-	2D
.	2E
/	2F
0	30
1	31
2	32
3	33
4	34
5	35
6	36
7	37
8	38
9	39
:	3A
;	3B
<	3C
=	3D
>	3E
?	3F
@	40
Aa	41,61
Bb	42,62
Cc	43,63
Dd	44,64
Ee	45,65
Ff	46,66
Gg	47,67
Hh	48,68
Ii	49,69
Jj	4A,6A
Kk	4B,6B
Ll	4C,6C
Mm	4D,6D
Nn	4E,6E
Oo	4F,6F
Pp	50,70
Qq	51,71
Rr	52,72
Ss	53,73
Tt	54,74
Uu	55,75
Vv	56,76
Ww	57,77
Xx	58,78
Yy~	59,79,7E
Zz	5A,7A
]	5D
[	5B
\	5C
^	5E
_	5F
`	60
{	7B
|	7C
}	7D
	7F
drop table t1;
SET collation_connection='gb2312_bin';
create table t1 select repeat('a',4000) a;
delete from t1;
insert into t1 values ('a'), ('a '), ('a\t');
select collation(a),hex(a) from t1 order by a;
collation(a)	hex(a)
gb2312_bin	6109
gb2312_bin	61
gb2312_bin	6120
drop table t1;
#
# MDEV-5453 Assertion `src' fails in my_strnxfrm_unicode on GROUP BY MID(..) WITH ROLLUP
#
SELECT @@collation_connection;
@@collation_connection
gb2312_bin
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 GROUP BY MID(CURRENT_USER,0) WITH ROLLUP;
i
1
1
SELECT * FROM t1 GROUP BY MID('test',0) WITH ROLLUP;
i
1
1
DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
select collation(c1) from t1 limit 1;
collation(c1)
gb2312_bin
select c1 from t1 where c1 like 'abcdef%' order by c1;
c1
abcdefg
select c1 from t1 where c1 like 'abcde1%' order by c1;
c1
abcde100
abcde110
abcde111
select c1 from t1 where c1 like 'abcde11%' order by c1;
c1
abcde110
abcde111
select c1 from t1 where c1 like 'abcde111%' order by c1;
c1
abcde111
drop table t1;
select @@collation_connection;
@@collation_connection
gb2312_bin
create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
insert into t1 values('abcdef');
insert into t1 values('_bcdef');
insert into t1 values('a_cdef');
insert into t1 values('ab_def');
insert into t1 values('abc_ef');
insert into t1 values('abcd_f');
insert into t1 values('abcde_');
select c1 as c1u from t1 where c1 like 'ab\_def';
c1u
ab_def
select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
INSERT INTO t1 (a, b) VALUES (1, repeat(0xF1F2,5));
INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10));
INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11));
INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12));
SELECT hex(concat(repeat(0xF1F2, 10), '%'));
hex(concat(repeat(0xF1F2, 10), '%'))
F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F225
3 rows expected
SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%');
a	hex(b)	c
2	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
3	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
4	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
DROP TABLE t1;
SET NAMES gb2312;
CREATE TABLE t1 (a text) character set gb2312;
INSERT INTO t1 VALUES (0xA2A1),(0xD7FE);
SELECT hex(a) FROM t1 ORDER BY a;
hex(a)
A2A1
D7FE
DROP TABLE t1;
#
# Start of 5.5 tests
#
#
# Testing WL#4583 Case conversion in Asian character sets 
#
SET NAMES utf8;
SET collation_connection=gb2312_chinese_ci;
CREATE TABLE t1 (b VARCHAR(2));
INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
DROP TABLE t1;
CREATE TABLE t1 AS
SELECT concat(head, tail) AS code, ' ' AS a
FROM head, tail
WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
ORDER BY head, tail;
DROP TEMPORARY TABLE head, tail;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `code` varchar(8) DEFAULT NULL,
  `a` varchar(1) CHARACTER SET gb2312 NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
UPDATE t1 SET a=unhex(code) ORDER BY code;
Warnings:
Warning	1366	Incorrect string value: '\x80 ' for column 'a' at row 1
Warning	1366	Incorrect string value: '\x80!' for column 'a' at row 2
Warning	1366	Incorrect string value: '\x80"' for column 'a' at row 3
Warning	1366	Incorrect string value: '\x80#' for column 'a' at row 4
Warning	1366	Incorrect string value: '\x80$' for column 'a' at row 5
Warning	1366	Incorrect string value: '\x80%' for column 'a' at row 6
Warning	1366	Incorrect string value: '\x80&' for column 'a' at row 7
Warning	1366	Incorrect string value: '\x80'' for column 'a' at row 8
Warning	1366	Incorrect string value: '\x80(' for column 'a' at row 9
Warning	1366	Incorrect string value: '\x80)' for column 'a' at row 10
Warning	1366	Incorrect string value: '\x80*' for column 'a' at row 11
Warning	1366	Incorrect string value: '\x80+' for column 'a' at row 12
Warning	1366	Incorrect string value: '\x80,' for column 'a' at row 13
Warning	1366	Incorrect string value: '\x80-' for column 'a' at row 14
Warning	1366	Incorrect string value: '\x80.' for column 'a' at row 15
Warning	1366	Incorrect string value: '\x80/' for column 'a' at row 16
Warning	1366	Incorrect string value: '\x800' for column 'a' at row 17
Warning	1366	Incorrect string value: '\x801' for column 'a' at row 18
Warning	1366	Incorrect string value: '\x802' for column 'a' at row 19
Warning	1366	Incorrect string value: '\x803' for column 'a' at row 20
Warning	1366	Incorrect string value: '\x804' for column 'a' at row 21
Warning	1366	Incorrect string value: '\x805' for column 'a' at row 22
Warning	1366	Incorrect string value: '\x806' for column 'a' at row 23
Warning	1366	Incorrect string value: '\x807' for column 'a' at row 24
Warning	1366	Incorrect string value: '\x808' for column 'a' at row 25
Warning	1366	Incorrect string value: '\x809' for column 'a' at row 26
Warning	1366	Incorrect string value: '\x80:' for column 'a' at row 27
Warning	1366	Incorrect string value: '\x80;' for column 'a' at row 28
Warning	1366	Incorrect string value: '\x80<' for column 'a' at row 29
Warning	1366	Incorrect string value: '\x80=' for column 'a' at row 30
Warning	1366	Incorrect string value: '\x80>' for column 'a' at row 31
Warning	1366	Incorrect string value: '\x80?' for column 'a' at row 32
Warning	1366	Incorrect string value: '\x80@' for column 'a' at row 33
Warning	1366	Incorrect string value: '\x80A' for column 'a' at row 34
Warning	1366	Incorrect string value: '\x80B' for column 'a' at row 35
Warning	1366	Incorrect string value: '\x80C' for column 'a' at row 36
Warning	1366	Incorrect string value: '\x80D' for column 'a' at row 37
Warning	1366	Incorrect string value: '\x80E' for column 'a' at row 38
Warning	1366	Incorrect string value: '\x80F' for column 'a' at row 39
Warning	1366	Incorrect string value: '\x80G' for column 'a' at row 40
Warning	1366	Incorrect string value: '\x80H' for column 'a' at row 41
Warning	1366	Incorrect string value: '\x80I' for column 'a' at row 42
Warning	1366	Incorrect string value: '\x80J' for column 'a' at row 43
Warning	1366	Incorrect string value: '\x80K' for column 'a' at row 44
Warning	1366	Incorrect string value: '\x80L' for column 'a' at row 45
Warning	1366	Incorrect string value: '\x80M' for column 'a' at row 46
Warning	1366	Incorrect string value: '\x80N' for column 'a' at row 47
Warning	1366	Incorrect string value: '\x80O' for column 'a' at row 48
Warning	1366	Incorrect string value: '\x80P' for column 'a' at row 49
Warning	1366	Incorrect string value: '\x80Q' for column 'a' at row 50
Warning	1366	Incorrect string value: '\x80R' for column 'a' at row 51
Warning	1366	Incorrect string value: '\x80S' for column 'a' at row 52
Warning	1366	Incorrect string value: '\x80T' for column 'a' at row 53
Warning	1366	Incorrect string value: '\x80U' for column 'a' at row 54
Warning	1366	Incorrect string value: '\x80V' for column 'a' at row 55
Warning	1366	Incorrect string value: '\x80W' for column 'a' at row 56
Warning	1366	Incorrect string value: '\x80X' for column 'a' at row 57
Warning	1366	Incorrect string value: '\x80Y' for column 'a' at row 58
Warning	1366	Incorrect string value: '\x80Z' for column 'a' at row 59
Warning	1366	Incorrect string value: '\x80[' for column 'a' at row 60
Warning	1366	Incorrect string value: '\x80\' for column 'a' at row 61
Warning	1366	Incorrect string value: '\x80]' for column 'a' at row 62
Warning	1366	Incorrect string value: '\x80^' for column 'a' at row 63
Warning	1366	Incorrect string value: '\x80_' for column 'a' at row 64
SELECT COUNT(*) FROM t1 WH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WL#3664 WEIGHT_STRING
#
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
select hex(weight_string('A'));
hex(weight_string('A'))
41
select hex(weight_string('abc'));
hex(weight_string('abc'))
414243
select hex(weight_string('abc' as char(2)));
hex(weight_string('abc' as char(2)))
4142
select hex(weight_string('abc' as char(3)));
hex(weight_string('abc' as char(3)))
414243
select hex(weight_string('abc' as char(5)));
hex(weight_string('abc' as char(5)))
4142432020
select hex(weight_string('abc', 1, 2, 0xC0));
hex(weight_string('abc', 1, 2, 0xC0))
41
select hex(weight_string('abc', 2, 2, 0xC0));
hex(weight_string('abc', 2, 2, 0xC0))
4142
select hex(weight_string('abc', 3, 2, 0xC0));
hex(weight_string('abc', 3, 2, 0xC0))
414220
select hex(weight_string('abc', 4, 2, 0xC0));
hex(weight_string('abc', 4, 2, 0xC0))
41422020
select hex(weight_string('abc', 5, 2, 0xC0));
hex(weight_string('abc', 5, 2, 0xC0))
4142202020
select hex(weight_string('abc',25, 2, 0xC0));
hex(weight_string('abc',25, 2, 0xC0))
41422020202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 3, 0xC0));
hex(weight_string('abc', 1, 3, 0xC0))
41
select hex(weight_string('abc', 2, 3, 0xC0));
hex(weight_string('abc', 2, 3, 0xC0))
4142
select hex(weight_string('abc', 3, 3, 0xC0));
hex(weight_string('abc', 3, 3, 0xC0))
414243
select hex(weight_string('abc', 4, 3, 0xC0));
hex(weight_string('abc', 4, 3, 0xC0))
41424320
select hex(weight_string('abc', 5, 3, 0xC0));
hex(weight_string('abc', 5, 3, 0xC0))
4142432020
select hex(weight_string('abc',25, 3, 0xC0));
hex(weight_string('abc',25, 3, 0xC0))
41424320202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 4, 0xC0));
hex(weight_string('abc', 1, 4, 0xC0))
41
select hex(weight_string('abc', 2, 4, 0xC0));
hex(weight_string('abc', 2, 4, 0xC0))
4142
select hex(weight_string('abc', 3, 4, 0xC0));
hex(weight_string('abc', 3, 4, 0xC0))
414243
select hex(weight_string('abc', 4, 4, 0xC0));
hex(weight_string('abc', 4, 4, 0xC0))
41424320
select hex(weight_string('abc', 5, 4, 0xC0));
hex(weight_string('abc', 5, 4, 0xC0))
4142432020
select hex(weight_string('abc',25, 4, 0xC0));
hex(weight_string('abc',25, 4, 0xC0))
41424320202020202020202020202020202020202020202020
select @@collation_connection;
@@collation_connection
gb2312_chinese_ci
select hex(weight_string('a' LEVEL 1));
hex(weight_string('a' LEVEL 1))
41
select hex(weight_string('A' LEVEL 1));
hex(weight_string('A' LEVEL 1))
41
select hex(weight_string('abc' LEVEL 1));
hex(weight_string('abc' LEVEL 1))
414243
select hex(weight_string('abc' as char(2) LEVEL 1));
hex(weight_string('abc' as char(2) LEVEL 1))
4142
select hex(weight_string('abc' as char(3) LEVEL 1));
hex(weight_string('abc' as char(3) LEVEL 1))
414243
select hex(weight_string('abc' as char(5) LEVEL 1));
hex(weight_string('abc' as char(5) LEVEL 1))
4142432020
select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
2020434241
select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
hex(weight_string('abc' as char(5) LEVEL 1 DESC))
BEBDBCDFDF
select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
DFDFBCBDBE
select collation(cast(0xA1A1 as char));
collation(cast(0xA1A1 as char))
gb2312_chinese_ci
select hex(weight_string(cast(0x6141 as char)));
hex(weight_string(cast(0x6141 as char)))
4141
select hex(weight_string(cast(0xA1A1 as char)));
hex(weight_string(cast(0xA1A1 as char)))
A1A1
select hex(weight_string(cast(0xA1A1 as char) as char(1)));
hex(weight_string(cast(0xA1A1 as char) as char(1)))
A1A1
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
A1A1
select hex(weight_string(cast(0xA1A1 as char) as char(3)));
hex(weight_string(cast(0xA1A1 as char) as char(3)))
A1A12020
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
A1A1A1A120
select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1 as char) as char(3)))
40A1A120
select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
40A1A1A1A1
select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
40A1A1A1A1
select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
4040A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
A1A1A1A120
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
A1A1A1A1202020202020202020202020202020202020202020
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
A1A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
A1A1A1A1A1A120202020202020202020202020202020202020
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
A1A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
A1A1A1A1A1A120202020202020202020202020202020202020
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
select hex(weight_string('A'));
hex(weight_string('A'))
41
select hex(weight_string('abc'));
hex(weight_string('abc'))
616263
select hex(weight_string('abc' as char(2)));
hex(weight_string('abc' as char(2)))
6162
select hex(weight_string('abc' as char(3)));
hex(weight_string('abc' as char(3)))
616263
select hex(weight_string('abc' as char(5)));
hex(weight_string('abc' as char(5)))
6162632020
select hex(weight_string('abc', 1, 2, 0xC0));
hex(weight_string('abc', 1, 2, 0xC0))
61
select hex(weight_string('abc', 2, 2, 0xC0));
hex(weight_string('abc', 2, 2, 0xC0))
6162
select hex(weight_string('abc', 3, 2, 0xC0));
hex(weight_string('abc', 3, 2, 0xC0))
616220
select hex(weight_string('abc', 4, 2, 0xC0));
hex(weight_string('abc', 4, 2, 0xC0))
61622020
select hex(weight_string('abc', 5, 2, 0xC0));
hex(weight_string('abc', 5, 2, 0xC0))
6162202020
select hex(weight_string('abc',25, 2, 0xC0));
hex(weight_string('abc',25, 2, 0xC0))
61622020202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 3, 0xC0));
hex(weight_string('abc', 1, 3, 0xC0))
61
select hex(weight_string('abc', 2, 3, 0xC0));
hex(weight_string('abc', 2, 3, 0xC0))
6162
select hex(weight_string('abc', 3, 3, 0xC0));
hex(weight_string('abc', 3, 3, 0xC0))
616263
select hex(weight_string('abc', 4, 3, 0xC0));
hex(weight_string('abc', 4, 3, 0xC0))
61626320
select hex(weight_string('abc', 5, 3, 0xC0));
hex(weight_string('abc', 5, 3, 0xC0))
6162632020
select hex(weight_string('abc',25, 3, 0xC0));
hex(weight_string('abc',25, 3, 0xC0))
61626320202020202020202020202020202020202020202020
select hex(weight_string('abc', 1, 4, 0xC0));
hex(weight_string('abc', 1, 4, 0xC0))
61
select hex(weight_string('abc', 2, 4, 0xC0));
hex(weight_string('abc', 2, 4, 0xC0))
6162
select hex(weight_string('abc', 3, 4, 0xC0));
hex(weight_string('abc', 3, 4, 0xC0))
616263
select hex(weight_string('abc', 4, 4, 0xC0));
hex(weight_string('abc', 4, 4, 0xC0))
61626320
select hex(weight_string('abc', 5, 4, 0xC0));
hex(weight_string('abc', 5, 4, 0xC0))
6162632020
select hex(weight_string('abc',25, 4, 0xC0));
hex(weight_string('abc',25, 4, 0xC0))
61626320202020202020202020202020202020202020202020
select @@collation_connection;
@@collation_connection
gb2312_bin
select hex(weight_string('a' LEVEL 1));
hex(weight_string('a' LEVEL 1))
61
select hex(weight_string('A' LEVEL 1));
hex(weight_string('A' LEVEL 1))
41
select hex(weight_string('abc' LEVEL 1));
hex(weight_string('abc' LEVEL 1))
616263
select hex(weight_string('abc' as char(2) LEVEL 1));
hex(weight_string('abc' as char(2) LEVEL 1))
6162
select hex(weight_string('abc' as char(3) LEVEL 1));
hex(weight_string('abc' as char(3) LEVEL 1))
616263
select hex(weight_string('abc' as char(5) LEVEL 1));
hex(weight_string('abc' as char(5) LEVEL 1))
6162632020
select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
2020636261
select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
hex(weight_string('abc' as char(5) LEVEL 1 DESC))
9E9D9CDFDF
select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
DFDF9C9D9E
select collation(cast(0xA1A1 as char));
collation(cast(0xA1A1 as char))
gb2312_bin
select hex(weight_string(cast(0x6141 as char)));
hex(weight_string(cast(0x6141 as char)))
6141
select hex(weight_string(cast(0xA1A1 as char)));
hex(weight_string(cast(0xA1A1 as char)))
A1A1
select hex(weight_string(cast(0xA1A1 as char) as char(1)));
hex(weight_string(cast(0xA1A1 as char) as char(1)))
A1A1
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
A1A1
select hex(weight_string(cast(0xA1A1 as char) as char(3)));
hex(weight_string(cast(0xA1A1 as char) as char(3)))
A1A12020
select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
A1A1A1A120
select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1 as char) as char(3)))
40A1A120
select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
40A1A1A1A1
select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
40A1A1A1A1
select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
4040A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
A1A1A1A120
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
A1A1A1A1202020202020202020202020202020202020202020
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
A1A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
A1A1A1A1A1A120202020202020202020202020202020202020
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
A1A1A1A1A1
select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
A1A1A1A1A1A120202020202020202020202020202020202020
#
# End of 5.6 tests
#
