1 CREATE
TABLE t1 (a CHAR(1)) CHARACTER SET utf8;
2 INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
3 INSERT INTO t1 VALUES ('8'),('9'),('
A'),('B'),('C'),('D'),('
E'),('F');
7 # Populate tables head and tail with values '00'-'FF'
9 CREATE TEMPORARY
TABLE head AS SELECT concat(b1.a, b2.a) AS head FROM t1 b1, t1 b2;
10 CREATE TEMPORARY
TABLE tail AS SELECT concat(b1.a, b2.a) AS tail FROM t1 b1, t1 b2;
11 CREATE TEMPORARY
TABLE middle AS SELECT concat(b1.a, b2.a) AS middle FROM t1 b1, t1 b2;
14 CREATE
TABLE t1 (a varchar(1)) CHARACTER SET utf8;
17 # Populate single byte characters
20 INSERT INTO t1 SELECT UNHEX(head)
21 FROM head WHERE (head BETWEEN '00' AND '7F')
ORDER BY head;
24 # Populate 2-byte byte characters: U+80..U+7FF: [C2-DF][80-BF]
27 SELECT UNHEX(CONCAT(head,tail))
29 WHERE (head BETWEEN 'C2' AND 'DF') AND (tail BETWEEN '80' AND 'BF')
34 # Populate 3-byte characters: U+800..U+FFFF: [E0-EF][80-BF][80-BF]
35 # excluding overlong [E0][80-9F][80-BF]
38 SELECT UNHEX(CONCAT(head, middle, tail))
39 FROM head, middle, tail
40 WHERE (head BETWEEN 'E0' AND 'EF')
41 AND (middle BETWEEN '80' AND 'BF')
42 AND (tail BETWEEN '80' AND 'BF')
43 AND NOT (head='E0' AND middle BETWEEN '80' AND '9F')
44 ORDER BY head, middle, tail;
47 SELECT count(*) FROM t1;