~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Tests with the utf8 character set
3
#
4
5
--disable_warnings
6
drop table if exists t1,t2;
7
--enable_warnings
8
759.1.5 by Monty Taylor
Enabled ctype_utf8.
9
select left(0xD0B0D0B1D0B2,1);
10
select right(0xD0B0D0B2D0B2,1);
1 by brian
clean slate
11
12
select locate('he','hello');
13
select locate('he','hello',2);
14
select locate('lo','hello',2);
15
select locate('HE','hello');
16
select locate('HE','hello',2);
17
select locate('LO','hello',2);
18
select locate('HE','hello' collate utf8_bin);
19
select locate('HE','hello' collate utf8_bin,2);
20
select locate('LO','hello' collate utf8_bin,2);
21
759.1.5 by Monty Taylor
Enabled ctype_utf8.
22
select locate(0xD0B1, 0xD0B0D0B1D0B2);
23
select locate(0xD091, 0xD0B0D0B1D0B2);
24
select locate(0xD0B1, 0xD0B0D091D0B2);
25
# TODO: Bug lp:314472
26
#select locate(0xD091, 0xD0B0D0B1D0B2 collate utf8_bin);
27
#select locate(0xD0B1, 0xD0B0D091D0B2 collate utf8_bin);
1 by brian
clean slate
28
1008.5.4 by lbieber
remove bit_length
29
select length(0xD0B1), char_length(0xD0B1);
1 by brian
clean slate
30
31
select 'a' like 'a';
32
select 'A' like 'a';
33
select 'A' like 'a' collate utf8_bin;
779.3.10 by Monty Taylor
Turned on -Wshadow.
34
select 0xD0B0D0B1D0B2 like concat('%',0xD0B1,'%');
1 by brian
clean slate
35
36
# Bug #6040: can't retrieve records with umlaut
37
# characters in case insensitive manner.
38
# Case insensitive search LIKE comparison
39
# was broken for multibyte characters:
759.1.5 by Monty Taylor
Enabled ctype_utf8.
40
select 'Günter André' like 'GÜNTER%';
1 by brian
clean slate
41
42
#
43
# Check the following:
44
# "a"  == "a "
45
# "a\0" < "a"
46
# "a\0" < "a "
47
48
SELECT 'a' = 'a ';
49
SELECT 'a\0' < 'a';
50
SELECT 'a\0' < 'a ';
51
SELECT 'a\t' < 'a';
52
SELECT 'a\t' < 'a ';
53
54
#
55
# The same for binary collation
56
#
57
SELECT 'a' = 'a ' collate utf8_bin;
58
SELECT 'a\0' < 'a' collate utf8_bin;
59
SELECT 'a\0' < 'a ' collate utf8_bin;
60
SELECT 'a\t' < 'a' collate utf8_bin;
61
SELECT 'a\t' < 'a ' collate utf8_bin;
62
759.1.5 by Monty Taylor
Enabled ctype_utf8.
63
CREATE TABLE t1 (a char(10) not null);
1 by brian
clean slate
64
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
65
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
66
DROP TABLE t1;
67
68
#
69
# Fix this, it should return 1:
70
#
779.3.10 by Monty Taylor
Turned on -Wshadow.
71
#select 0xD0B0D0B1D0B2 like concat('%',0xD091,'%');
1 by brian
clean slate
72
#
73
74
#
75
# Bug 2367: INSERT() behaviour is different for different charsets.
76
#
77
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
78
select insert("aa",100,1,"b"),insert("aa",1,3,"b");
79
80
#
81
# LELF() didn't work well with utf8 in some cases too.
82
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
83
select char_length(left(@a:='න ',5)), length(@a), @a;
1 by brian
clean slate
84
85
86
#
87
# CREATE ... SELECT
88
#
89
create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
90
show create table t1;
91
select * from t1;
92
drop table t1;
93
759.1.5 by Monty Taylor
Enabled ctype_utf8.
94
95
96
# TODO: Bug lp:314474
97
#create table t1 (s1 tinytext);
98
#insert into t1 select repeat('a',300);
99
#insert into t1 select repeat('Ñ',300);
100
#insert into t1 select repeat('aÑ',300);
101
#insert into t1 select repeat('Ña',300);
102
#insert into t1 select repeat('ÑÑ',300);
103
#select hex(s1) from t1;
104
#select length(s1),char_length(s1) from t1;
105
#drop table t1;
106
107
#create table t1 (s1 text);
108
#insert into t1 select repeat('a',66000);
109
#insert into t1 select repeat('Ñ',66000);
110
#insert into t1 select repeat('aÑ',66000);
111
#insert into t1 select repeat('Ña',66000);
112
#insert into t1 select repeat('ÑÑ',66000);
113
#select length(s1),char_length(s1) from t1;
114
#drop table t1;
1 by brian
clean slate
115
116
#
117
# Bug #2368 Multibyte charsets do not check that incoming data is well-formed
118
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
119
create table t1 (s1 char(10));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
120
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
759.1.5 by Monty Taylor
Enabled ctype_utf8.
121
insert into t1 values (0x41FF);
122
select hex(s1) from t1;
123
drop table t1;
124
125
create table t1 (s1 varchar(10));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
126
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
759.1.5 by Monty Taylor
Enabled ctype_utf8.
127
insert into t1 values (0x41FF);
128
select hex(s1) from t1;
129
drop table t1;
130
131
create table t1 (s1 text);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
132
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1 by brian
clean slate
133
insert into t1 values (0x41FF);
134
select hex(s1) from t1;
135
drop table t1;
136
137
#
138
# Bug 2699
139
# UTF8 breaks primary keys for cols > 333 characters
140
#
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
141
--error ER_TOO_LONG_KEY
1441 by Brian Aker
Fixing tests to work with PBXT.
142
create table t1 (a text, primary key(a(360))) engine=innodb;
1 by brian
clean slate
143
144
#
145
# Bug 2959
146
# UTF8 charset breaks joins with mixed column/string constant
147
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
148
CREATE TABLE t1 ( a varchar(10) );
1 by brian
clean slate
149
INSERT INTO t1 VALUES ( 'test' );
150
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
151
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
152
SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
153
DROP TABLE t1;
154
759.1.5 by Monty Taylor
Enabled ctype_utf8.
155
create table t1 (a char(255));
1 by brian
clean slate
156
insert into t1 values('b'),('b');
157
select * from t1 where a = 'b';
158
select * from t1 where a = 'b' and a = 'b';
159
select * from t1 where a = 'b' and a != 'b';
160
drop table t1;
161
162
#
163
# Bug #4555
164
# ALTER TABLE crashes mysqld with enum column collated utf8_unicode_ci
165
#
166
CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8_unicode_ci);
167
ALTER TABLE t1 ADD COLUMN b CHAR(20);
168
DROP TABLE t1;
169
170
# Customer Support Center issue # 3299 
171
# ENUM and SET multibyte fields computed their length wronly 
172
# when converted into a char field
759.1.5 by Monty Taylor
Enabled ctype_utf8.
173
# TODO: Bug lp:314502
174
#create table t1 (a enum('aaaa', '킱'));
175
#show create table t1;
176
#insert into t1 values ('킱');
177
#select * from t1;
178
#create table t2 select ifnull(a,a) from t1;
179
#show create table t2;
180
#select * from t2;
181
#drop table t1;
182
#drop table t2;
1 by brian
clean slate
183
184
#
185
# Bug 4521: unique key prefix interacts poorly with utf8
186
# MYISAM: keys with prefix compression, case insensitive collation.
187
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
188
create table t1 (c varchar(30), unique(c(10)));
1 by brian
clean slate
189
insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
190
insert into t1 values ('aaaaaaaaaa');
191
--error ER_DUP_ENTRY
192
insert into t1 values ('aaaaaaaaaaa');
193
--error ER_DUP_ENTRY
194
insert into t1 values ('aaaaaaaaaaaa');
195
insert into t1 values (repeat('b',20));
196
select c c1 from t1 where c='1';
197
select c c2 from t1 where c='2';
198
select c c3 from t1 where c='3';
199
select c cx from t1 where c='x';
200
select c cy from t1 where c='y';
201
select c cz from t1 where c='z';
202
select c ca10 from t1 where c='aaaaaaaaaa';
203
select c cb20 from t1 where c=repeat('b',20);
204
drop table t1;
205
206
#
207
# Bug 4521: unique key prefix interacts poorly with utf8
208
# InnoDB: keys with prefix compression, case insensitive collation.
209
#
210
--disable_warnings
759.1.5 by Monty Taylor
Enabled ctype_utf8.
211
create table t1 (c varchar(30), unique(c(10))) engine=innodb;
1 by brian
clean slate
212
--enable_warnings
213
insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
214
insert into t1 values ('aaaaaaaaaa');
215
--error ER_DUP_ENTRY
216
insert into t1 values ('aaaaaaaaaaa');
217
--error ER_DUP_ENTRY
218
insert into t1 values ('aaaaaaaaaaaa');
219
insert into t1 values (repeat('b',20));
220
select c c1 from t1 where c='1';
221
select c c2 from t1 where c='2';
222
select c c3 from t1 where c='3';
223
select c cx from t1 where c='x';
224
select c cy from t1 where c='y';
225
select c cz from t1 where c='z';
226
select c ca10 from t1 where c='aaaaaaaaaa';
227
select c cb20 from t1 where c=repeat('b',20);
228
drop table t1;
229
#
230
# Bug 4521: unique key prefix interacts poorly with utf8
231
# MYISAM: fixed length keys, case insensitive collation
232
#
1063.9.3 by Brian Aker
Partial fix for tests for tmp
233
create TEMPORARY table t1 (c char(3), unique (c(2))) engine=myisam;
1 by brian
clean slate
234
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
235
insert into t1 values ('a');
236
insert into t1 values ('aa');
237
--error ER_DUP_ENTRY
238
insert into t1 values ('aaa');
239
insert into t1 values ('b');
240
insert into t1 values ('bb');
241
--error ER_DUP_ENTRY
242
insert into t1 values ('bbb');
759.1.5 by Monty Taylor
Enabled ctype_utf8.
243
insert into t1 values ('킱');
244
insert into t1 values ('킱킱');
245
--error ER_DUP_ENTRY
246
insert into t1 values ('킱킱킱');
1 by brian
clean slate
247
drop table t1;
248
#
249
# Bug 4521: unique key prefix interacts poorly with utf8
250
# InnoDB: fixed length keys, case insensitive collation
251
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
252
create table t1 (c char(3), unique (c(2))) engine=innodb;
1 by brian
clean slate
253
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
254
insert into t1 values ('a');
255
insert into t1 values ('aa');
256
--error ER_DUP_ENTRY
257
insert into t1 values ('aaa');
258
insert into t1 values ('b');
259
insert into t1 values ('bb');
260
--error ER_DUP_ENTRY
261
insert into t1 values ('bbb');
759.1.5 by Monty Taylor
Enabled ctype_utf8.
262
insert into t1 values ('킱');
263
insert into t1 values ('킱킱');
264
--error ER_DUP_ENTRY
265
insert into t1 values ('킱킱킱');
1 by brian
clean slate
266
drop table t1;
267
#
268
# Bug 4531: unique key prefix interacts poorly with utf8
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
269
# Check MEMORY+HASH, case insensitive collation
1 by brian
clean slate
270
#
1106.3.1 by Brian Aker
Heap is now tmp only table
271
create TEMPORARY table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
272
c char(10),
273
unique key a using hash (c(2))
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
274
) engine=MEMORY;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
275
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
276
insert into t1 values ('a');
1 by brian
clean slate
277
insert into t1 values ('aa');
278
--error ER_DUP_ENTRY
279
insert into t1 values ('aaa');
759.1.5 by Monty Taylor
Enabled ctype_utf8.
280
insert into t1 values ('b');
281
insert into t1 values ('bb');
282
--error ER_DUP_ENTRY
283
insert into t1 values ('bbb');
284
insert into t1 values ('킱');
285
insert into t1 values ('킱킱');
286
--error ER_DUP_ENTRY
287
insert into t1 values ('킱킱킱');
1 by brian
clean slate
288
select c as c_all from t1 order by c;
289
select c as c_a from t1 where c='a';
759.1.5 by Monty Taylor
Enabled ctype_utf8.
290
select c as c_a from t1 where c='킱';
1 by brian
clean slate
291
drop table t1;
292
293
#
294
# Bug 4531: unique key prefix interacts poorly with utf8
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
295
# Check MEMORY+BTREE, case insensitive collation
1 by brian
clean slate
296
#
1106.3.1 by Brian Aker
Heap is now tmp only table
297
create TEMPORARY table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
298
c char(10),
299
unique key a using btree (c(2))
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
300
) engine=MEMORY;
1 by brian
clean slate
301
show create table t1;
302
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
303
insert into t1 values ('a');
304
insert into t1 values ('aa');
305
--error ER_DUP_ENTRY
306
insert into t1 values ('aaa');
307
insert into t1 values ('b');
308
insert into t1 values ('bb');
309
--error ER_DUP_ENTRY
310
insert into t1 values ('bbb');
759.1.5 by Monty Taylor
Enabled ctype_utf8.
311
insert into t1 values ('킱');
312
insert into t1 values ('킱킱');
313
--error ER_DUP_ENTRY
314
insert into t1 values ('킱킱킱');
315
select c as c_all from t1 order by c;
316
select c as c_a from t1 where c='a';
317
select c as c_a from t1 where c='킱';
1 by brian
clean slate
318
drop table t1;
319
320
321
# Bug#4594: column index make = failed for gbk, but like works
322
# Check MYISAM
323
#
1063.9.3 by Brian Aker
Partial fix for tests for tmp
324
create TEMPORARY table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
325
  str varchar(255) not null,
1 by brian
clean slate
326
  key str  (str(2))
327
) engine=myisam;
328
INSERT INTO t1 VALUES ('str');
329
INSERT INTO t1 VALUES ('str2');
330
select * from t1 where str='str';
331
drop table t1;
332
333
# Bug#4594: column index make = failed for gbk, but like works
334
# Check InnoDB
335
#
336
--disable_warnings
337
create table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
338
  str varchar(255) not null,
1 by brian
clean slate
339
  key str  (str(2))
340
) engine=innodb;
341
--enable_warnings
342
INSERT INTO t1 VALUES ('str');
343
INSERT INTO t1 VALUES ('str2');
344
select * from t1 where str='str';
345
drop table t1;
346
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
347
# the same for MEMORY+BTREE
1 by brian
clean slate
348
#
349
1106.3.1 by Brian Aker
Heap is now tmp only table
350
create temporary table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
351
  str varchar(255) not null,
1 by brian
clean slate
352
  key str using btree (str(2))
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
353
) engine=MEMORY;
1 by brian
clean slate
354
INSERT INTO t1 VALUES ('str');
355
INSERT INTO t1 VALUES ('str2');
356
select * from t1 where str='str';
357
drop table t1;
358
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
359
# the same for MEMORY+HASH
1 by brian
clean slate
360
#
361
1106.3.1 by Brian Aker
Heap is now tmp only table
362
create temporary table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
363
  str varchar(255) not null,
1 by brian
clean slate
364
  key str using hash (str(2))
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
365
) engine=MEMORY;
1 by brian
clean slate
366
INSERT INTO t1 VALUES ('str');
367
INSERT INTO t1 VALUES ('str2');
368
select * from t1 where str='str';
369
drop table t1;
370
371
# the same for BDB
372
#
373
374
--disable_warnings
375
create table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
376
  str varchar(255) not null,
1 by brian
clean slate
377
  key str (str(2))
378
) engine=innodb;
379
--enable_warnings
380
INSERT INTO t1 VALUES ('str');
381
INSERT INTO t1 VALUES ('str2');
382
select * from t1 where str='str';
383
drop table t1;
384
385
#
386
# Bug #5397: Crash with varchar binary and LIKE
387
#
1217 by Brian Aker
Removed bits of charset support from the parser.
388
CREATE TABLE t1 (a varchar(32));
1 by brian
clean slate
389
INSERT INTO t1 VALUES ('test');
390
SELECT a FROM t1 WHERE a LIKE '%te';
391
DROP TABLE t1;
392
393
#
394
# Bug #5723: length(<varchar utf8 field>) returns varying results
395
#
396
--disable_warnings
397
CREATE TABLE t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
398
  subject varchar(255) collate utf8_unicode_ci,
399
  p varchar(15)
400
) ENGINE=InnoDB;
1 by brian
clean slate
401
--enable_warnings
759.1.5 by Monty Taylor
Enabled ctype_utf8.
402
INSERT INTO t1 values ('킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱','abcdefghijklmno');
1 by brian
clean slate
403
INSERT INTO t1 VALUES ('aaa','bbb');
404
SELECT length(subject) FROM t1;
405
SELECT length(subject) FROM t1 ORDER BY 1;
406
DROP TABLE t1;
407
408
#
409
# Bug #5832 SELECT doesn't return records in some cases
410
#
1063.9.3 by Brian Aker
Partial fix for tests for tmp
411
CREATE TEMPORARY TABLE t1 (
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
412
    id       int NOT NULL auto_increment,
413
    list_id  int NOT NULL,
1 by brian
clean slate
414
    term     TEXT NOT NULL,
415
    PRIMARY KEY(id),
416
    INDEX(list_id, term(4))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
417
) ENGINE=MYISAM;
1 by brian
clean slate
418
INSERT INTO t1 SET list_id = 1, term = "letterc";
419
INSERT INTO t1 SET list_id = 1, term = "letterb";
420
INSERT INTO t1 SET list_id = 1, term = "lettera";
421
INSERT INTO t1 SET list_id = 1, term = "letterd";
422
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
423
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
424
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
425
SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
426
DROP TABLE t1;
427
428
429
#
430
# Bug #6043 erratic searching for diacriticals in indexed MyISAM UTF-8 table
431
#
1063.9.3 by Brian Aker
Partial fix for tests for tmp
432
CREATE TEMPORARY TABLE t1 (
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
433
    id int NOT NULL auto_increment,
434
    list_id int NOT NULL,
1 by brian
clean slate
435
    term text NOT NULL,
436
    PRIMARY KEY(id),
437
    INDEX(list_id, term(19))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
438
) ENGINE=MyISAM;
439
INSERT INTO t1 set list_id = 1, term = "testétest";
1 by brian
clean slate
440
INSERT INTO t1 set list_id = 1, term = "testetest";
759.1.5 by Monty Taylor
Enabled ctype_utf8.
441
INSERT INTO t1 set list_id = 1, term = "testètest";
442
SELECT id, term FROM t1 where (list_id = 1) AND (term = "testétest");
1 by brian
clean slate
443
SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest");
759.1.5 by Monty Taylor
Enabled ctype_utf8.
444
SELECT id, term FROM t1 where (list_id = 1) AND (term = "testètest");
1 by brian
clean slate
445
DROP TABLE t1;
446
447
#
448
# Bug #6019 SELECT tries to use too short prefix index on utf8 data
449
#
450
--disable_warnings
451
create table t1 (
452
  a int primary key,
453
  b varchar(6),
454
  index b3(b(3))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
455
) engine=innodb;
1 by brian
clean slate
456
--enable_warnings
457
insert into t1 values(1,'foo'),(2,'foobar');
458
select * from t1 where b like 'foob%';
459
--disable_warnings
460
alter table t1 engine=innodb;
461
--enable_warnings
462
select * from t1 where b like 'foob%';
463
drop table t1;
464
465
#
466
# Test for calculate_interval_lengths() function
467
#
468
create table t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
469
  a enum('','','') not null default ''
1 by brian
clean slate
470
);
779.3.10 by Monty Taylor
Turned on -Wshadow.
471
create table t2 select concat(a,'') as a from t1;
1 by brian
clean slate
472
show create table t2;
473
drop table t2;
474
drop table t1;
475
476
#
477
# Bug #6787 LIKE not working properly with _ and utf8 data
478
#
479
select 'c' like '\_' as want0; 
480
481
#
482
# SUBSTR with negative offset didn't work with multi-byte strings
483
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
484
SELECT SUBSTR('☃☄킱',-2);
485
486
1 by brian
clean slate
487
-- source include/ctype_filesort.inc
488
-- source include/ctype_like_escape.inc
489
-- source include/ctype_german.inc
490
-- source include/ctype_filesort.inc
491
-- source include/ctype_like_escape.inc
492
759.1.5 by Monty Taylor
Enabled ctype_utf8.
493
1 by brian
clean slate
494
495
#
496
# Bugs#5980: NULL requires a characterset in a union
497
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
498
create table t1 (a varchar(10));
1 by brian
clean slate
499
insert into t1 values ('test');
500
select ifnull(a,'') from t1;
501
drop table t1;
779.3.10 by Monty Taylor
Turned on -Wshadow.
502
select repeat('+',3) as h union select NULL;
503
select ifnull(NULL, 'string');
1 by brian
clean slate
504
505
#
506
# Bug#9509 Optimizer: wrong result after AND with comparisons
507
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
508
create table t1 (s1 char(5) collate utf8_lithuanian_ci);
1 by brian
clean slate
509
insert into t1 values ('I'),('K'),('Y');
510
select * from t1 where s1 < 'K' and s1 = 'Y';
511
select * from t1 where 'K' > s1 and s1 = 'Y';
512
drop table t1;
513
759.1.5 by Monty Taylor
Enabled ctype_utf8.
514
create table t1 (s1 char(5) collate utf8_czech_ci);
1 by brian
clean slate
515
insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
516
select * from t1 where s1 > 'd' and s1 = 'CH';
517
select * from t1 where 'd' < s1 and s1 = 'CH';
518
select * from t1 where s1 = 'cH' and s1 <> 'ch';
519
select * from t1 where 'cH' = s1 and s1 <> 'ch';
520
drop table t1;
521
522
#
523
# Bug#10714: Inserting double value into utf8 column crashes server
524
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
525
create table t1 (a varchar(255));
1 by brian
clean slate
526
insert into t1 values (1.0);
527
drop table t1;
528
529
#
530
# Bug#10253 compound index length and utf8 char set
531
# produces invalid query results
532
#
533
create table t1 (
534
 id int not null,
535
 city varchar(20) not null,
536
 key (city(7),id)
759.1.5 by Monty Taylor
Enabled ctype_utf8.
537
);
1 by brian
clean slate
538
insert into t1 values (1,'Durban North');
539
insert into t1 values (2,'Durban');
540
select * from t1 where city = 'Durban';
541
select * from t1 where city = 'Durban ';
542
drop table t1;
543
544
#
545
#
546
# Test for bug #11167: join for utf8 varchar value longer than 255 bytes 
547
#
548
1063.9.3 by Brian Aker
Partial fix for tests for tmp
549
CREATE TEMPORARY TABLE t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
550
  `id` int NOT NULL auto_increment,
1 by brian
clean slate
551
  `country` varchar(100) NOT NULL default '',
552
  `shortcode` varchar(100) NOT NULL default '',
553
  `operator` varchar(100) NOT NULL default '',
554
  `momid` varchar(30) NOT NULL default '',
555
  `keyword` varchar(160) NOT NULL default '',
556
  `content` varchar(160) NOT NULL default '',
557
  `second_token` varchar(160) default NULL,
759.1.5 by Monty Taylor
Enabled ctype_utf8.
558
  `gateway_id` int NOT NULL default '0',
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
559
  `created` datetime NULL,
1 by brian
clean slate
560
  `msisdn` varchar(15) NOT NULL default '',
561
  PRIMARY KEY  (`id`),
562
  UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
563
  KEY `IX_mobile_originated_message_keyword` (`keyword`),
564
  KEY `IX_mobile_originated_message_created` (`created`),
565
  KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
759.1.5 by Monty Taylor
Enabled ctype_utf8.
566
) ENGINE=MyISAM;
1 by brian
clean slate
567
568
INSERT INTO t1 VALUES 
759.1.5 by Monty Taylor
Enabled ctype_utf8.
569
(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱킱','G', 3,'2005-06-01 17:30:43','1234567890'),
1 by brian
clean slate
570
(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
571
572
--disable_warnings
573
CREATE TABLE t2 (
574
  `msisdn` varchar(15) NOT NULL default '',
759.1.5 by Monty Taylor
Enabled ctype_utf8.
575
  `operator_id` int NOT NULL default '0',
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
576
  `created` datetime NULL,
1 by brian
clean slate
577
  UNIQUE KEY `PK_user` (`msisdn`)
759.1.5 by Monty Taylor
Enabled ctype_utf8.
578
) ENGINE=InnoDB;
1 by brian
clean slate
579
--enable_warnings
580
581
INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
582
583
SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
584
585
DROP TABLE t1,t2;
586
587
#
588
# Bug#11591: CHAR column with utf8 does not work properly
589
# (more chars than expected)
590
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
591
create table t1 (a char(20));
592
insert into t1 values ('12'),('킱킲');
593
alter table t1 modify a char(2);
1 by brian
clean slate
594
select char_length(a), length(a), a from t1 order by a;
595
drop table t1;
596
597
#
598
# Bugs#12611
599
# ESCAPE + LIKE do not work when the escape char is a multibyte one
600
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
601
select 'andre%' like 'andre킱%' escape '킱';
1 by brian
clean slate
602
603
#
604
# Bugs#11754: SET NAMES utf8 followed by SELECT "A\\" LIKE "A\\" returns 0
605
#
606
select 'a\\' like 'a\\';
607
select 'aa\\' like 'a%\\';
608
759.1.5 by Monty Taylor
Enabled ctype_utf8.
609
create table t1 (a char(10), key(a));
1 by brian
clean slate
610
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
611
select * from t1 where a like "abc%";
612
select * from t1 where a like concat("abc","%");
613
select * from t1 where a like "ABC%";
614
select * from t1 where a like "test%";
615
select * from t1 where a like "te_t";
616
select * from t1 where a like "%a%";
617
select * from t1 where a like "%abcd%";
618
select * from t1 where a like "%abc\d%";
619
drop table t1;
620
621
622
#
623
# Bug#9557 MyISAM utf8 table crash
624
#
1063.9.3 by Brian Aker
Partial fix for tests for tmp
625
CREATE TEMPORARY TABLE t1 (
1 by brian
clean slate
626
  a varchar(255) NOT NULL default '',
627
  KEY a (a)
1245.3.4 by Stewart Smith
make the equals of KEY=VALUE required for CREATE TABLE options
628
) ENGINE=MyISAM COLLATE=utf8_general_ci;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
629
insert into t1 values (0xe880bd);
630
insert into t1 values (0x5b);
1 by brian
clean slate
631
select hex(a) from t1;
632
drop table t1;
633
634
#
635
# Bug#13751 find_in_set: Illegal mix of collations
636
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
637
create table t1 (a varchar(255));
1 by brian
clean slate
638
select * from t1 where find_in_set('-1', a);
639
drop table t1;
640
641
#
642
# Bug#13233: select distinct char(column) fails with utf8
643
#
644
create table t1 (a int);
645
insert into t1 values (48),(49),(50);
646
select distinct char(a) from t1;
647
drop table t1;
648
649
#
650
# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
651
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
652
CREATE TABLE t1 (t TINYTEXT);
1 by brian
clean slate
653
INSERT INTO t1 VALUES(REPEAT('a', 100));
654
CREATE TEMPORARY TABLE t2 SELECT COALESCE(t) AS bug FROM t1;
655
SELECT LENGTH(bug) FROM t2;
656
DROP TABLE t2;
657
DROP TABLE t1;
658
659
#
779.3.10 by Monty Taylor
Turned on -Wshadow.
660
# Bug#17313: N'xxx' and 'xxx' are not equivalent
1 by brian
clean slate
661
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
662
CREATE TABLE t1 (item varchar(255));
663
INSERT INTO t1 VALUES ('\\');
779.3.10 by Monty Taylor
Turned on -Wshadow.
664
INSERT INTO t1 VALUES ('\\');
665
INSERT INTO t1 VALUES ('Cote d\'Ivoire');
666
INSERT INTO t1 VALUES ('Cote d\'Ivoire');
1 by brian
clean slate
667
SELECT item FROM t1 ORDER BY item;
668
DROP TABLE t1;
669
670
#
671
# Bug#17705: Corruption of compressed index when index length changes between
672
# 254 and 256
673
#
674
675
DROP TABLE IF EXISTS t1;
1063.9.3 by Brian Aker
Partial fix for tests for tmp
676
CREATE TEMPORARY TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
677
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
1 by brian
clean slate
678
INSERT INTO t1 VALUES('uu');
679
check table t1;
680
INSERT INTO t1 VALUES('uU');
681
check table t1;
682
INSERT INTO t1 VALUES('uu');
683
check table t1;
684
INSERT INTO t1 VALUES('uuABC');
685
check table t1;
686
INSERT INTO t1 VALUES('UuABC');
687
check table t1;
688
INSERT INTO t1 VALUES('uuABC');
689
check table t1;
690
alter table t1 add b int;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
691
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
692
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
1 by brian
clean slate
693
delete from t1 where b=1;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
694
INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
1 by brian
clean slate
695
check table t1;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
696
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
697
INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
1 by brian
clean slate
698
delete from t1 where b=3;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
699
INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZÌbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
1 by brian
clean slate
700
check table t1;
701
drop table t1;
702
703
#
704
# Bug#20471 LIKE search fails with indexed utf8 char column
705
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
706
create table t1 (s1 char(5));
707
insert into t1 values
708
('a'),('b'),(null),('킁aaaa'),('ü'),('Y');
709
create index it1 on t1 (s1);
710
select s1 as before_delete_general_ci from t1 where s1 like '킁aaa%';
711
delete from t1 where s1 = 'Y';
712
select s1 as after_delete_general_ci from t1 where s1 like '킁aaa%';
713
drop table t1;
714
715
create table t1 (s1 char(5) collate utf8_unicode_ci);
716
insert into t1 values
717
('a'),('b'),(null),('킁aaaa'),('ü'),('Y');
718
create index it1 on t1 (s1);
719
select s1 as before_delete_unicode_ci from t1 where s1 like '킁aaa%';
720
delete from t1 where s1 = 'Y';
721
select s1 as after_delete_unicode_ci from t1 where s1 like '킁aaa%';
722
drop table t1;
723
724
create table t1 (s1 char(5) collate utf8_bin);
725
insert into t1 values
726
('a'),('b'),(null),('킁aaaa'),('ü'),('Y');
727
create index it1 on t1 (s1);
728
select s1 as before_delete_bin from t1 where s1 like '킁aaa%';
729
delete from t1 where s1 = 'Y';
730
select s1 as after_delete_bin from t1 where s1 like '킁aaa%';
731
drop table t1;
732
1 by brian
clean slate
733
734
735
736
#
737
# Bug#14896: Comparison with a key in a partial index over mb chararacter field
738
#
739
1063.9.3 by Brian Aker
Partial fix for tests for tmp
740
CREATE TEMPORARY TABLE t1 (id int PRIMARY KEY,
1 by brian
clean slate
741
                 a varchar(16) collate utf8_unicode_ci NOT NULL default '',
742
                 b int,
743
                 f varchar(128) default 'XXX',
744
                 INDEX (a(4))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
745
) ENGINE=MyISAM COLLATE=utf8_unicode_ci;
1 by brian
clean slate
746
INSERT INTO t1(id, a, b) VALUES
747
  (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
748
  (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
749
  (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
750
  (10, 'eeeee', 40), (11, 'bbbbbb', 60);
751
752
SELECT id, a, b FROM t1;
753
754
SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
755
756
SELECT id, a FROM t1 WHERE a='bbbbbb';
757
SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
758
759
DROP TABLE t1;
760
761
#
762
# Bug#16674: LIKE predicate for a utf8 character set column
763
#
764
1063.9.3 by Brian Aker
Partial fix for tests for tmp
765
CREATE TEMPORARY TABLE t1 (
1 by brian
clean slate
766
  a CHAR(13) DEFAULT '',
767
  INDEX(a)
759.1.5 by Monty Taylor
Enabled ctype_utf8.
768
) ENGINE=MyISAM COLLATE=utf8_general_ci;
1 by brian
clean slate
769
INSERT INTO t1 VALUES 
759.1.5 by Monty Taylor
Enabled ctype_utf8.
770
 ('KÃli KÃli 2-4'), ('KÃli KÃli 2-4'),
771
 ('KÃli KÃli 2+4'), ('KÃli KÃli 2+4'),
772
 ('KÃli KÃli 2-6'), ('KÃli KÃli 2-6');
1063.9.3 by Brian Aker
Partial fix for tests for tmp
773
CREATE TABLE t2 SELECT * FROM t1;
774
INSERT INTO t1 SELECT * FROM t2;
775
DROP TABLE t2;
1 by brian
clean slate
776
759.1.5 by Monty Taylor
Enabled ctype_utf8.
777
SELECT a FROM t1 WHERE a LIKE 'KÃli KÃli 2+4';
778
779
EXPLAIN SELECT a FROM t1 WHERE a LIKE 'KÃli KÃli 2+4';
780
EXPLAIN SELECT a FROM t1 WHERE a = 'KÃli KÃli 2+4';
781
782
DROP TABLE t1;
1 by brian
clean slate
783
1063.9.3 by Brian Aker
Partial fix for tests for tmp
784
CREATE TEMPORARY TABLE t1 (
1 by brian
clean slate
785
  a char(255) DEFAULT '', 
786
  KEY(a(10))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
787
) ENGINE=MyISAM COLLATE=utf8_general_ci;
788
INSERT INTO t1 VALUES ('KÃli KÃli 2-4');
789
SELECT * FROM t1 WHERE a LIKE 'KÃli KÃli 2%';
790
INSERT INTO t1 VALUES ('KÃli KÃli 2-4');
791
SELECT * FROM t1 WHERE a LIKE 'KÃli KÃli 2%';
1 by brian
clean slate
792
DROP TABLE t1;
793
1063.9.3 by Brian Aker
Partial fix for tests for tmp
794
CREATE TEMPORARY TABLE t1 (
1 by brian
clean slate
795
  a char(255) DEFAULT ''
759.1.5 by Monty Taylor
Enabled ctype_utf8.
796
) ENGINE=MyISAM COLLATE=utf8_general_ci;
797
INSERT INTO t1 VALUES ('KÃli KÃli 2-4');
798
INSERT INTO t1 VALUES ('KÃli KÃli 2-4');
799
SELECT * FROM t1 WHERE a LIKE 'KÃli KÃli 2%';
1 by brian
clean slate
800
ALTER TABLE t1 ADD KEY (a(10));
759.1.5 by Monty Taylor
Enabled ctype_utf8.
801
SELECT * FROM t1 WHERE a LIKE 'KÃli KÃli 2%';
1 by brian
clean slate
802
DROP TABLE t1;
803
804
#
805
# Bug#18359: LIKE predicate for a 'utf8' text column with a partial index
806
#            (see bug #16674 as well)
807
#
808
1063.9.3 by Brian Aker
Partial fix for tests for tmp
809
CREATE TEMPORARY TABLE t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
810
  id int NOT NULL default '0',
811
  tid int NOT NULL default '0',
1 by brian
clean slate
812
  val text NOT NULL,
813
  INDEX idx(tid, val(10))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
814
) ENGINE=MyISAM;
1 by brian
clean slate
815
816
INSERT INTO t1 VALUES
759.1.5 by Monty Taylor
Enabled ctype_utf8.
817
  (40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'),
818
  (41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'),
819
  (41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'),
820
  (42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'),
821
  (42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL');
1 by brian
clean slate
822
823
SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; 
759.1.5 by Monty Taylor
Enabled ctype_utf8.
824
SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; 
825
SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL'; 
1 by brian
clean slate
826
827
ALTER TABLE t1 DROP KEY idx;
828
ALTER TABLE t1 ADD KEY idx (tid,val(11));
829
759.1.5 by Monty Taylor
Enabled ctype_utf8.
830
SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; 
1 by brian
clean slate
831
832
DROP TABLE t1;
833
834
#
835
# Bug 20709: problem with utf8 fields in temporary tables
836
#
837
838
create table t1(a char(200) collate utf8_unicode_ci NOT NULL default '')
759.1.5 by Monty Taylor
Enabled ctype_utf8.
839
  collate=utf8_unicode_ci;
1 by brian
clean slate
840
insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
841
explain select distinct a from t1;
842
select distinct a from t1;
843
explain select a from t1 group by a;
844
select a from t1 group by a;
845
drop table t1;
846
847
#
848
# Bug #20204: "order by" changes the results returned
849
#
850
759.1.5 by Monty Taylor
Enabled ctype_utf8.
851
create table t1(a char(10));
1 by brian
clean slate
852
insert into t1 values ('123'), ('456');
853
explain
854
  select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
855
select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
856
drop table t1;
857
858
# End of 4.1 tests
859
860
#
861
# Test for bug #11484: wrong results for a DISTINCT varchar column in uft8. 
862
#
863
759.1.5 by Monty Taylor
Enabled ctype_utf8.
864
CREATE TABLE t1(id varchar(20) NOT NULL);
1 by brian
clean slate
865
INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
866
867
SELECT id FROM t1;
868
SELECT DISTINCT id FROM t1;
869
SELECT DISTINCT id FROM t1 ORDER BY id;
870
871
DROP TABLE t1;
872
759.1.5 by Monty Taylor
Enabled ctype_utf8.
873
1 by brian
clean slate
874
875
#
876
# char() without USING returns "binary" by default, any argument is ok
877
#
878
select hex(char(195));
879
select hex(char(196));
880
select hex(char(2557));
881
882
883
884
#
885
# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters
886
#
759.1.5 by Monty Taylor
Enabled ctype_utf8.
887
create table t1 (a char(1));
888
create table t2 (a char(1));
1 by brian
clean slate
889
insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
890
insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
891
select * from t1 union distinct select * from t2;
892
drop table t1,t2;
893
894
895
896
# Conversion tests for "text_literal TEXT_STRING_literal" syntax structure
759.1.5 by Monty Taylor
Enabled ctype_utf8.
897
create table t1 (a varchar(10), b int);
1 by brian
clean slate
898
insert into t1 values ('a',1);
899
select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
900
select concat(a, if(b>10, 'x' 'æ', 'y' '')) from t1;
1 by brian
clean slate
901
drop table t1;
902
903
904
#
905
# Bug#19960: Inconsistent results when joining
906
# InnoDB tables using partial UTF8 indexes
907
#
908
--disable_warnings
909
CREATE TABLE t1 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
910
  colA int NOT NULL,
911
  colB varchar(255) NOT NULL,
1 by brian
clean slate
912
   PRIMARY KEY  (colA)
759.1.5 by Monty Taylor
Enabled ctype_utf8.
913
) ENGINE=InnoDB;
1 by brian
clean slate
914
--enable_warnings
915
INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
916
--disable_warnings
917
CREATE TABLE t2 (
759.1.5 by Monty Taylor
Enabled ctype_utf8.
918
  colA int NOT NULL,
919
  colB varchar(255) NOT NULL,
1 by brian
clean slate
920
   KEY bad  (colA,colB(3))
759.1.5 by Monty Taylor
Enabled ctype_utf8.
921
) ENGINE=InnoDB;
1 by brian
clean slate
922
--enable_warnings
923
INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
924
SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
925
WHERE t1.colA < 3;
926
DROP TABLE t1, t2;
927
928
#
929
# Bug#29205: truncation of UTF8 values when the UNION statement
930
# forces collation to the binary charset
931
#
932
779.3.10 by Monty Taylor
Turned on -Wshadow.
933
SELECT '½1234567890' UNION SELECT '1';
759.1.5 by Monty Taylor
Enabled ctype_utf8.
934
SELECT '½1234567890' UNION SELECT 1;
935
936
SELECT '1' UNION SELECT '1234567890';
937
SELECT 1 UNION SELECT '1234567890';
938
939
CREATE TABLE t1 (c VARCHAR(11));
940
CREATE TABLE t2 (b CHAR(1), i INT);
941
942
INSERT INTO t1 (c) VALUES ('1234567890');
1 by brian
clean slate
943
INSERT INTO t2 (b, i) VALUES ('1', 1);
944
945
SELECT c FROM t1 UNION SELECT b FROM t2;
946
SELECT c FROM t1 UNION SELECT i FROM t2;
947
948
SELECT b FROM t2 UNION SELECT c FROM t1;
949
SELECT i FROM t2 UNION SELECT c FROM t1;
950
951
DROP TABLE t1, t2;
952
953
954
#
955
# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
956
#
957
--disable_warnings
958
DROP TABLE IF EXISTS t1;
959
--enable_warnings
960
CREATE TABLE t1 (
961
        predicted_order int NOT NULL,
962
        utf8_encoding VARCHAR(10) NOT NULL
759.1.5 by Monty Taylor
Enabled ctype_utf8.
963
);
1 by brian
clean slate
964
INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
965
SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
966
DROP TABLE t1;
967
968
--echo End of 5.1 tests
969
970
#
971
# Check strnxfrm() with odd length
972
#
973
set max_sort_length=5;
974
select @@max_sort_length;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
975
create table t1 (a varchar(128) collate utf8_general_ci);
1 by brian
clean slate
976
insert into t1 values ('a'),('b'),('c');
977
select * from t1 order by a;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
978
alter table t1 modify a varchar(128) collate utf8_bin;
1 by brian
clean slate
979
select * from t1 order by a;
980
drop table t1;
981
set max_sort_length=default;
982
983
#
984
# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
985
#
986
--disable_warnings
987
DROP TABLE IF EXISTS t1;
988
--enable_warnings
989
CREATE TABLE t1 (
990
        predicted_order int NOT NULL,
991
        utf8_encoding VARCHAR(10) NOT NULL
759.1.5 by Monty Taylor
Enabled ctype_utf8.
992
);
1 by brian
clean slate
993
INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
994
SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
995
DROP TABLE t1;
996
820.3.8 by Padraig
Added test case for the other bug resolved in this branch.
997
#
998
# Bug#309118
999
# When warning of a cast truncation occurs the reported warning
1000
# shows the wrong char size in it
1001
#
1002
select CAST(' ' as char(1));
1003
show warnings;
759.1.5 by Monty Taylor
Enabled ctype_utf8.
1004
820.3.24 by Padraig
Added test case for Bug#319796.
1005
#
1006
# Bug#319796
1007
# When a UTF8 string is used as a column alias it is truncated
1008
# incorrectly.
1009
#
1010
SELECT "☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃☃";