|
| 1 | +--echo # |
| 2 | +--echo # Start of ctype_thai.inc |
| 3 | +--echo # |
| 4 | + |
| 5 | +# |
| 6 | +# Test Unicode Thai collations based on libthai testcases |
| 7 | +# |
| 8 | + |
| 9 | +CREATE TABLE t1 (a VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_bin); |
| 10 | + |
| 11 | +INSERT INTO t1 VALUES ('-กระแย่ง'); |
| 12 | +INSERT INTO t1 VALUES ('กก'); |
| 13 | +INSERT INTO t1 VALUES ('กราบ'); |
| 14 | +INSERT INTO t1 VALUES ('ข่าง'); |
| 15 | +INSERT INTO t1 VALUES ('ข้าง'); |
| 16 | +INSERT INTO t1 VALUES ('ข้างกระดาน'); |
| 17 | +INSERT INTO t1 VALUES ('ข้างขึ้น'); |
| 18 | +INSERT INTO t1 VALUES ('ข้างควาย'); |
| 19 | +INSERT INTO t1 VALUES ('ข้างเงิน'); |
| 20 | +INSERT INTO t1 VALUES ('ข้างแรม'); |
| 21 | +INSERT INTO t1 VALUES ('ข้างออก'); |
| 22 | +INSERT INTO t1 VALUES ('ข้างๆ'); |
| 23 | +INSERT INTO t1 VALUES ('ข้างๆ คูๆ'); |
| 24 | +INSERT INTO t1 VALUES ('ขาง'); |
| 25 | +INSERT INTO t1 VALUES ('แข็ง'); |
| 26 | +INSERT INTO t1 VALUES ('แข่ง'); |
| 27 | +INSERT INTO t1 VALUES ('แข่งขัน'); |
| 28 | +INSERT INTO t1 VALUES ('แข้ง'); |
| 29 | +INSERT INTO t1 VALUES ('แข้งขวา'); |
| 30 | +INSERT INTO t1 VALUES ('แข็งขัน'); |
| 31 | +INSERT INTO t1 VALUES ('ทูลเกล้า'); |
| 32 | +INSERT INTO t1 VALUES ('ทูลเกล้าทูลกระหม่อม'); |
| 33 | +INSERT INTO t1 VALUES ('ทูลเกล้าฯ'); |
| 34 | +INSERT INTO t1 VALUES ('บุญญา'); |
| 35 | +INSERT INTO t1 VALUES ('บุญ-หลง'); |
| 36 | +INSERT INTO t1 VALUES ('บุญหลง'); |
| 37 | +INSERT INTO t1 VALUES ('ป่า'); |
| 38 | +INSERT INTO t1 VALUES ('ป่าน'); |
| 39 | +INSERT INTO t1 VALUES ('ป้า'); |
| 40 | +INSERT INTO t1 VALUES ('ป้าน'); |
| 41 | +INSERT INTO t1 VALUES ('ป๊า'); |
| 42 | +INSERT INTO t1 VALUES ('ป๊าน'); |
| 43 | +INSERT INTO t1 VALUES ('ป๋า'); |
| 44 | +INSERT INTO t1 VALUES ('ป๋าน'); |
| 45 | +INSERT INTO t1 VALUES ('ปา'); |
| 46 | +INSERT INTO t1 VALUES ('ปาน'); |
| 47 | +INSERT INTO t1 VALUES ('แป้ง'); |
| 48 | +INSERT INTO t1 VALUES ('พณิชย์'); |
| 49 | +INSERT INTO t1 VALUES ('ม้า'); |
| 50 | +INSERT INTO t1 VALUES ('ฯพณฯ'); |
| 51 | +INSERT INTO t1 VALUES ('A'); |
| 52 | +INSERT INTO t1 VALUES ('a'); |
| 53 | +INSERT INTO t1 VALUES ('a\''); |
| 54 | +INSERT INTO t1 VALUES ('A-'); |
| 55 | +INSERT INTO t1 VALUES ('a-'); |
| 56 | +INSERT INTO t1 VALUES ('-a'); |
| 57 | +INSERT INTO t1 VALUES ('A.'); |
| 58 | +INSERT INTO t1 VALUES ('a.'); |
| 59 | +INSERT INTO t1 VALUES ('A-1'); |
| 60 | +INSERT INTO t1 VALUES ('aa'); |
| 61 | +INSERT INTO t1 VALUES ('AA'); |
| 62 | +INSERT INTO t1 VALUES ('A.A.'); |
| 63 | +INSERT INTO t1 VALUES ('a.a.'); |
| 64 | +INSERT INTO t1 VALUES ('AAA'); |
| 65 | +INSERT INTO t1 VALUES ('A.A.A.'); |
| 66 | +INSERT INTO t1 VALUES ('AAAA'); |
| 67 | +INSERT INTO t1 VALUES ('A.A.A.L.'); |
| 68 | +INSERT INTO t1 VALUES ('A.A.A.S.'); |
| 69 | +INSERT INTO t1 VALUES ('Aachen'); |
| 70 | +INSERT INTO t1 VALUES ('A.A.E.'); |
| 71 | +INSERT INTO t1 VALUES ('A.Ae.E.'); |
| 72 | +INSERT INTO t1 VALUES ('A.A.E.E.'); |
| 73 | +INSERT INTO t1 VALUES ('AAES'); |
| 74 | +INSERT INTO t1 VALUES ('AAF'); |
| 75 | +INSERT INTO t1 VALUES ('A.Agr'); |
| 76 | +INSERT INTO t1 VALUES ('aah'); |
| 77 | +INSERT INTO t1 VALUES ('@@@@@'); |
| 78 | +INSERT INTO t1 VALUES ('0000'); |
| 79 | +INSERT INTO t1 VALUES ('9999'); |
| 80 | +INSERT INTO t1 VALUES ('Aalborg'); |
| 81 | +INSERT INTO t1 VALUES ('aide'); |
| 82 | +INSERT INTO t1 VALUES ('air'); |
| 83 | +INSERT INTO t1 VALUES ('@@@air'); |
| 84 | +INSERT INTO t1 VALUES ('air@@@'); |
| 85 | +INSERT INTO t1 VALUES ('C.A.F'); |
| 86 | +INSERT INTO t1 VALUES ('Canon'); |
| 87 | +INSERT INTO t1 VALUES ('coop'); |
| 88 | +INSERT INTO t1 VALUES ('co-op'); |
| 89 | +INSERT INTO t1 VALUES ('COOP'); |
| 90 | +INSERT INTO t1 VALUES ('CO-OP'); |
| 91 | +INSERT INTO t1 VALUES ('Copenhegen'); |
| 92 | +INSERT INTO t1 VALUES ('McArthur'); |
| 93 | +INSERT INTO t1 VALUES ('Mc Arthur'); |
| 94 | +INSERT INTO t1 VALUES ('Mc Mahon'); |
| 95 | +INSERT INTO t1 VALUES ('vice-president'); |
| 96 | +INSERT INTO t1 VALUES ('vice versa'); |
| 97 | +INSERT INTO t1 VALUES ('vice-versa'); |
| 98 | +INSERT INTO t1 VALUES ('10 ลิตร'); |
| 99 | +INSERT INTO t1 VALUES ('๑๐ ลิตร'); |
| 100 | +INSERT INTO t1 VALUES ('10 litre'); |
| 101 | +INSERT INTO t1 VALUES ('10 litre (10 ลิตร)'); |
| 102 | +INSERT INTO t1 VALUES ('10 ลิตร (10 litre)'); |
| 103 | +INSERT INTO t1 VALUES ('10 litre (๑๐ ลิตร)'); |
| 104 | +INSERT INTO t1 VALUES ('๑๐ ลิตร (10 litre)'); |
| 105 | +INSERT INTO t1 VALUES ('๑๐ ลิตร [10 litre]'); |
| 106 | +INSERT INTO t1 VALUES ('๑๐ ลิตร {10 litre}'); |
| 107 | + |
| 108 | +# Sort the table according to binary 'a' |
| 109 | +# To avoid problems with unpredictable order or 'AA' and 'aa' |
| 110 | +ALTER TABLE t1 ORDER BY a; |
| 111 | + |
| 112 | +SET @backup_character_set_connection=@@character_set_connection; |
| 113 | +SET @backup_collation_connection=@@collation_connection; |
| 114 | +SET NAMES utf8; |
| 115 | +SET @stmt= CONCAT('ALTER TABLE t1 MODIFY a VARCHAR(30)', |
| 116 | + ' CHARACTER SET ', @backup_character_set_connection, |
| 117 | + ' COLLATE ', @backup_collation_connection, |
| 118 | + ' , ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY' |
| 119 | + ' , ADD KEY a_id (a, id)'); |
| 120 | +PREPARE stmt FROM @stmt; |
| 121 | +EXECUTE stmt; |
| 122 | +DEALLOCATE PREPARE stmt; |
| 123 | +SET collation_connection=@backup_collation_connection; |
| 124 | + |
| 125 | +SHOW CREATE TABLE t1; |
| 126 | + |
| 127 | +--echo # |
| 128 | +--echo # Ascending sort, using filesort |
| 129 | +--echo # |
| 130 | +EXPLAIN SELECT a FROM t1 ORDER BY a, BINARY a; |
| 131 | +SELECT a FROM t1 ORDER BY a, BINARY a; |
| 132 | + |
| 133 | +--echo # |
| 134 | +--echo # Descending sort, using filesort |
| 135 | +--echo # |
| 136 | +EXPLAIN SELECT a FROM t1 ORDER BY a DESC, BINARY a DESC; |
| 137 | +SELECT a FROM t1 ORDER BY a DESC, BINARY a DESC; |
| 138 | + |
| 139 | + |
| 140 | +--echo # |
| 141 | +--echo # Ascending sort, using index |
| 142 | +--echo # |
| 143 | +EXPLAIN SELECT a FROM t1 ORDER BY a, id; |
| 144 | +SELECT a FROM t1 ORDER BY a, id; |
| 145 | + |
| 146 | +--echo # |
| 147 | +--echo # Descending sort, using index |
| 148 | +--echo # |
| 149 | +EXPLAIN SELECT a FROM t1 ORDER BY a DESC, id DESC; |
| 150 | +SELECT a FROM t1 ORDER BY a DESC, id DESC; |
| 151 | + |
| 152 | +DROP TABLE t1; |
| 153 | + |
| 154 | +--echo # |
| 155 | +--echo # End of ctype_thai.inc |
| 156 | +--echo # |
0 commit comments