mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / ctype_ucs.test
blob05d564b3de2624301528917645e0ee229aaae07f
1 -- source include/have_ucs2.inc
3 --disable_warnings
4 DROP TABLE IF EXISTS t1;
5 --enable_warnings
7 SET @test_character_set= 'ucs2';
8 SET @test_collation= 'ucs2_general_ci';
9 -- source include/ctype_common.inc
11 SET NAMES latin1;
12 SET character_set_connection=ucs2;
13 -- source include/endspace.inc
15 SET CHARACTER SET koi8r;
18 # BUG#49028, error in LIKE with ucs2
20 create table t1 (a varchar(2) character set ucs2 collate ucs2_bin, key(a));
21 insert into t1 values ('A'),('A'),('B'),('C'),('D'),('A\t');
22 insert into t1 values ('A\0'),('A\0'),('A\0'),('A\0'),('AZ');
23 select hex(a) from t1 where a like 'A_' order by a;
24 select hex(a) from t1 ignore key(a) where a like 'A_' order by a;
25 drop table t1;
28 # Check that 0x20 is only trimmed when it is 
29 # a part of real SPACE character, not just a part
30 # of a multibyte sequence.
31 # Note, CYRILLIC LETTER ER is used as an example, which
32 # is stored as 0x0420 in UCS2, thus contains 0x20 in the
33 # low byte. The second character is THREE-PER-M, U+2004,
34 # which contains 0x20 in the high byte.
37 CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2, word2 CHAR(64) CHARACTER SET ucs2);
38 INSERT INTO t1 VALUES (_koi8r'ò',_koi8r'ò'), (X'2004',X'2004');
39 SELECT hex(word) FROM t1 ORDER BY word;
40 SELECT hex(word2) FROM t1 ORDER BY word2;
41 DELETE FROM t1;
44 # Check that real spaces are correctly trimmed.
47 INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020');
48 SELECT hex(word) FROM t1 ORDER BY word;
49 SELECT hex(word2) FROM t1 ORDER BY word2;
50 DROP TABLE t1;
53 # Check LPAD/RPAD
55 SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'0421');
56 SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
57 SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
58 SELECT LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
60 SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'0421');
61 SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
62 SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
63 SELECT RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
65 CREATE TABLE t1 SELECT 
66 LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l,
67 RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r;
68 SHOW CREATE TABLE t1;
69 DROP TABLE t1;
71 --echo #
72 --echo # Bug #51876 : crash/memory underrun when loading data with ucs2 
73 --echo #   and reverse() function
74 --echo #
76 --echo # Problem # 1 (original report): wrong parsing of ucs2 data
77 SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt';
78 CREATE TABLE t1(a INT);
79 LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2
80 (@b) SET a=REVERSE(@b);
81 --echo # should return 2 zeroes (as the value is truncated)
82 SELECT * FROM t1;
84 DROP TABLE t1;
85 let $MYSQLD_DATADIR= `select @@datadir`;
86 remove_file $MYSQLD_DATADIR/test/tmpp.txt;
89 --echo # Problem # 2 : if you write and read ucs2 data to a file they're lost
90 SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2;
91 CREATE TABLE t1(a INT);
92 LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2
93 (@b) SET a=REVERSE(@b);
94 --echo # should return 0 and 1 (10 reversed)
95 SELECT * FROM t1;
97 DROP TABLE t1;
98 let $MYSQLD_DATADIR= `select @@datadir`;
99 remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
104 # BUG3946
107 create table t2(f1 Char(30));
108 insert into t2 values ("103000"), ("22720000"), ("3401200"), ("78000");
109 select lpad(f1, 12, "-o-/") from t2;
110 drop table t2;
112 ######################################################
114 # Test of like
117 SET NAMES koi8r;
118 SET character_set_connection=ucs2;
120 create table t1 (a varchar(10) character set ucs2, key(a));
121 insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
122 explain select * from t1 where a like 'abc%';
123 explain select * from t1 where a like concat('abc','%');
124 select * from t1 where a like "abc%";
125 select * from t1 where a like concat("abc","%");
126 select * from t1 where a like "ABC%";
127 select * from t1 where a like "test%";
128 select * from t1 where a like "te_t";
129 select * from t1 where a like "%a%";
130 select * from t1 where a like "%abcd%";
131 select * from t1 where a like "%abc\d%";
132 drop table t1;
135 # More LIKE test: bug#2619
137 select 'AA' like 'AA'; 
138 select 'AA' like 'A%A';
139 select 'AA' like 'A%%A';
140 select 'AA' like 'AA%';
141 select 'AA' like '%AA%';
142 select 'AA' like '%A';
143 select 'AA' like '%AA';
144 select 'AA' like 'A%A%';
145 select 'AA' like '_%_%';
146 select 'AA' like '%A%A';
147 select 'AAA'like 'A%A%A';
149 select 'AZ' like 'AZ'; 
150 select 'AZ' like 'A%Z';
151 select 'AZ' like 'A%%Z';
152 select 'AZ' like 'AZ%';
153 select 'AZ' like '%AZ%';
154 select 'AZ' like '%Z';
155 select 'AZ' like '%AZ';
156 select 'AZ' like 'A%Z%';
157 select 'AZ' like '_%_%';
158 select 'AZ' like '%A%Z';
159 select 'AZ' like 'A_';
160 select 'AZ' like '_Z';
161 select 'AMZ'like 'A%M%Z';
163 CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
164 INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
165 INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
166 INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
167 INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
168 SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
169 SELECT * FROM t1 WHERE a LIKE '%Æù×%';
170 SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
171 SELECT * FROM t1 WHERE a LIKE 'Æù×Á%' COLLATE ucs2_bin;
172 DROP TABLE t1;
175 # Bug 1181
177 CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word))
178 ENGINE=MyISAM CHARACTER SET ucs2 COLLATE ucs2_general_ci;
179 INSERT INTO t1 (word) VALUES ("cat");
180 SELECT * FROM t1 WHERE word LIKE "c%";
181 SELECT * FROM t1 WHERE word LIKE "ca_";
182 SELECT * FROM t1 WHERE word LIKE "cat";
183 SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';
184 SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
185 DROP TABLE t1;
188 # Check that INSERT works fine. 
189 # This invokes charpos() function.
190 select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066);
191 select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066);
193 ######################################################
196 # Bug 1264
198 # Description: 
200 # When using a ucs2 table in MySQL, 
201 # either with ucs2_general_ci or ucs2_bin collation,
202 # words are returned in an incorrect order when using ORDER BY
203 # on an _indexed_ CHAR or VARCHAR column. They are sorted with
204 # the longest word *first* instead of last. I.E. The word "aardvark"
205 # is in the results before the word "a".
207 # If there is no index for the column, the problem does not occur.
209 # Interestingly, if there is no second column, the words are returned
210 # in the correct order. 
212 # According to EXPLAIN, it looks like when the output includes columns that
213 # are not part of the index sorted on, it does a filesort, which fails. 
214 # Using a straight index yields correct results.
216 SET NAMES latin1;
219 # Two fields, index
222 CREATE TABLE t1 (
223    word VARCHAR(64),
224    bar INT(11) default 0,
225    PRIMARY KEY (word))
226    ENGINE=MyISAM
227    CHARSET ucs2
228    COLLATE ucs2_general_ci ;
230 INSERT INTO t1 (word) VALUES ("aar");
231 INSERT INTO t1 (word) VALUES ("a");
232 INSERT INTO t1 (word) VALUES ("aardvar");
233 INSERT INTO t1 (word) VALUES ("aardvark");
234 INSERT INTO t1 (word) VALUES ("aardvara");
235 INSERT INTO t1 (word) VALUES ("aardvarz");
236 EXPLAIN SELECT * FROM t1 ORDER BY word;
237 SELECT * FROM t1 ORDER BY word;
238 EXPLAIN SELECT word FROM t1 ORDER BY word;
239 SELECT word FROM t1 ORDER by word;
240 DROP TABLE t1;
243 # One field, index
246 CREATE TABLE t1 (
247    word VARCHAR(64) ,
248    PRIMARY KEY (word))
249    ENGINE=MyISAM
250    CHARSET ucs2
251    COLLATE ucs2_general_ci;
253 INSERT INTO t1 (word) VALUES ("aar");
254 INSERT INTO t1 (word) VALUES ("a");
255 INSERT INTO t1 (word) VALUES ("aardvar");
256 INSERT INTO t1 (word) VALUES ("aardvark");
257 INSERT INTO t1 (word) VALUES ("aardvara");
258 INSERT INTO t1 (word) VALUES ("aardvarz");
259 EXPLAIN SELECT * FROM t1 ORDER BY WORD;
260 SELECT * FROM t1 ORDER BY word;
261 DROP TABLE t1;
265 # Two fields, no index
268 CREATE TABLE t1 (
269    word TEXT,
270    bar INT(11) AUTO_INCREMENT,
271    PRIMARY KEY (bar))
272    ENGINE=MyISAM
273    CHARSET ucs2
274    COLLATE ucs2_general_ci ;
275 INSERT INTO t1 (word) VALUES ("aar");
276 INSERT INTO t1 (word) VALUES ("a" );
277 INSERT INTO t1 (word) VALUES ("aardvar");
278 INSERT INTO t1 (word) VALUES ("aardvark");
279 INSERT INTO t1 (word) VALUES ("aardvara");
280 INSERT INTO t1 (word) VALUES ("aardvarz");
281 EXPLAIN SELECT * FROM t1 ORDER BY word;
282 SELECT * FROM t1 ORDER BY word;
283 EXPLAIN SELECT word FROM t1 ORDER BY word;
284 SELECT word FROM t1 ORDER BY word;
285 DROP TABLE t1;
288 # END OF Bug 1264 test
290 ########################################################
293 # Bug #2390
294 # Check alignment for constants
296 SELECT HEX(_ucs2 0x0);
297 SELECT HEX(_ucs2 0x01);
298 SELECT HEX(_ucs2 0x012);
299 SELECT HEX(_ucs2 0x0123);
300 SELECT HEX(_ucs2 0x01234);
301 SELECT HEX(_ucs2 0x012345);
302 SELECT HEX(_ucs2 0x0123456);
303 SELECT HEX(_ucs2 0x01234567);
304 SELECT HEX(_ucs2 0x012345678);
305 SELECT HEX(_ucs2 0x0123456789);
306 SELECT HEX(_ucs2 0x0123456789A);
307 SELECT HEX(_ucs2 0x0123456789AB);
308 SELECT HEX(_ucs2 0x0123456789ABC);
309 SELECT HEX(_ucs2 0x0123456789ABCD);
310 SELECT HEX(_ucs2 0x0123456789ABCDE);
311 SELECT HEX(_ucs2 0x0123456789ABCDEF);
314 # Check alignment for from-binary-conversion with CAST and CONVERT
316 SELECT hex(cast(0xAA as char character set ucs2));
317 SELECT hex(convert(0xAA using ucs2));
320 # Check alignment for string types
322 CREATE TABLE t1 (a char(10) character set ucs2);
323 INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
324 SELECT HEX(a) FROM t1;
325 DROP TABLE t1;
327 CREATE TABLE t1 (a varchar(10) character set ucs2);
328 INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
329 SELECT HEX(a) FROM t1;
330 DROP TABLE t1;
332 CREATE TABLE t1 (a text character set ucs2);
333 INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
334 SELECT HEX(a) FROM t1;
335 DROP TABLE t1;
337 CREATE TABLE t1 (a mediumtext character set ucs2);
338 INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
339 SELECT HEX(a) FROM t1;
340 DROP TABLE t1;
342 CREATE TABLE t1 (a longtext character set ucs2);
343 INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
344 SELECT HEX(a) FROM t1;
345 DROP TABLE t1;
347 # the same should be also done with enum and set
351 # Bug #5024 Server crashes with queries on fields
352 #  with certain charset/collation settings
355 create table t1 (s1 char character set `ucs2` collate `ucs2_czech_ci`);
356 insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c');
357 select s1 from t1 where s1 > 'a' order by s1;
358 drop table t1;
361 # Bug #5081 : UCS2 fields are filled with '0x2020'
362 # after extending field length
364 create table t1(a char(1)) default charset = ucs2;
365 insert into t1 values ('a'),('b'),('c');
366 alter table t1 modify a char(5);
367 select a, hex(a) from t1;
368 drop table t1;
371 # Check prepare statement from an UCS2 string
373 set @ivar= 1234;
374 set @str1 = 'select ?';
375 set @str2 = convert(@str1 using ucs2);
376 prepare stmt1 from @str2;
377 execute stmt1 using @ivar;
380 # Check that ucs2 works with ENUM and SET type
382 set names latin1;
383 create table t1 (a enum('x','y','z') character set ucs2);
384 show create table t1;
385 insert into t1 values ('x');
386 insert into t1 values ('y');
387 insert into t1 values ('z');
388 select a, hex(a) from t1 order by a;
389 alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set ucs2;
390 show create table t1;
391 insert into t1 values ('D');
392 insert into t1 values ('E ');
393 insert into t1 values ('Ä');
394 insert into t1 values ('Ö');
395 insert into t1 values ('Ü');
396 select a, hex(a) from t1 order by a;
397 drop table t1;
399 create table t1 (a set ('x','y','z','ä','ö','ü') character set ucs2);
400 show create table t1;
401 insert into t1 values ('x');
402 insert into t1 values ('y');
403 insert into t1 values ('z');
404 insert into t1 values ('x,y');
405 insert into t1 values ('x,y,z,Ä,Ö,Ü');
406 select a, hex(a) from t1 order by a;
407 drop table t1;
410 # Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
412 create table t1(a enum('a','b','c')) default character set ucs2;
413 insert into t1 values('a'),('b'),('c');
414 alter table t1 add b char(1);
415 show warnings;
416 select * from t1 order by a;
417 drop table t1;
419 SET collation_connection='ucs2_general_ci';
420 -- source include/ctype_filesort.inc
421 -- source include/ctype_like_escape.inc
422 -- source include/ctype_german.inc
423 -- source include/ctype_like_range_f1f2.inc
424 SET NAMES latin1;
425 SET collation_connection='ucs2_bin';
426 -- source include/ctype_filesort.inc
427 -- source include/ctype_like_escape.inc
428 -- source include/ctype_like_range_f1f2.inc
431 # Bug#10344 Some string functions fail for UCS2
433 select hex(substr(_ucs2 0x00e400e50068,1));
434 select hex(substr(_ucs2 0x00e400e50068,2));
435 select hex(substr(_ucs2 0x00e400e50068,3));
436 select hex(substr(_ucs2 0x00e400e50068,-1));
437 select hex(substr(_ucs2 0x00e400e50068,-2));
438 select hex(substr(_ucs2 0x00e400e50068,-3));
440 SET NAMES latin1;
442 # Bug#8235
444 # This bug also helped to find another problem that
445 # INSERT of a UCS2 string containing a negative number
446 # into a unsigned int column didn't produce warnings.
447 # This test covers both problems.
449 SET collation_connection='ucs2_swedish_ci';
450 CREATE TABLE t1 (Field1 int(10) default '0');
451 # no warnings, negative numbers are allowed
452 INSERT INTO t1 VALUES ('-1');
453 SELECT * FROM t1;
454 DROP TABLE t1;
455 CREATE TABLE t1 (Field1 int(10) unsigned default '0');
456 # this should generate a "Data truncated" warning
457 INSERT INTO t1 VALUES ('-1');
458 DROP TABLE t1;
459 SET NAMES latin1;
462 # Bug#18691 Converting number to UNICODE string returns invalid result
464 SELECT CONVERT(103, CHAR(50) UNICODE);
465 SELECT CONVERT(103.0, CHAR(50) UNICODE);
466 SELECT CONVERT(-103, CHAR(50) UNICODE);
467 SELECT CONVERT(-103.0, CHAR(50) UNICODE);
470 # Bug#9557 MyISAM utf8 table crash
472 CREATE TABLE t1 (
473   a varchar(255) NOT NULL default '',
474   KEY a (a)
475 ) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE ucs2_general_ci;
476 insert into t1 values (0x803d);
477 insert into t1 values (0x005b);
478 select hex(a) from t1;
479 drop table t1;
482 # Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation
484 --disable_warnings
485 create table t1(f1 varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL) engine=InnoDB;
486 --enable_warnings
487 insert into t1 values('a');
488 create index t1f1 on t1(f1);
489 select f1 from t1 where f1 like 'a%';
490 drop table t1;
493 # Bug#9442 Set parameter make query fail if column character set is UCS2
495 create table t1 (utext varchar(20) character set ucs2);
496 insert into t1 values ("lily");
497 insert into t1 values ("river");
498 prepare stmt from 'select utext from t1 where utext like ?';
499 set @param1='%%';
500 execute stmt using @param1;
501 execute stmt using @param1;
502 select utext from t1 where utext like '%%';
503 drop table t1;
504 deallocate prepare stmt;
507 # Bug#22052 Trailing spaces are not removed from UNICODE fields in an index
509 create table t1 (
510   a char(10) unicode not null, 
511   index a (a)
512 ) engine=myisam;
513 insert into t1 values (repeat(0x201f, 10));
514 insert into t1 values (repeat(0x2020, 10));
515 insert into t1 values (repeat(0x2021, 10));
516 # make sure "index read" is used
517 explain select hex(a) from t1 order by a;
518 select hex(a) from t1 order by a;
519 alter table t1 drop index a;
520 select hex(a) from t1 order by a;
521 drop table t1;
524 # Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
525 #             over a 'ucs2' field uses a temporary table 
528 CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
529 INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
531 SELECT id, MIN(s) FROM t1 GROUP BY id;
533 DROP TABLE t1;
536 # Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
539 --disable_warnings
540 drop table if exists bug20536;
541 --enable_warnings
543 set names latin1;
544 create table bug20536 (id bigint not null auto_increment primary key, name
545 varchar(255) character set ucs2 not null);
546 insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
547 select md5(name) from bug20536;
548 select sha1(name) from bug20536;
549 select make_set(3, name, upper(name)) from bug20536;
550 select export_set(5, name, upper(name)) from bug20536;
551 select export_set(5, name, upper(name), ",", 5) from bug20536;
554 # Bug #20108: corrupted default enum value for a ucs2 field              
557 CREATE TABLE t1 (
558   status enum('active','passive') collate latin1_general_ci 
559     NOT NULL default 'passive'
561 SHOW CREATE TABLE t1;
562 ALTER TABLE t1 ADD a int NOT NULL AFTER status; 
564 CREATE TABLE t2 (
565   status enum('active','passive') collate ucs2_turkish_ci 
566     NOT NULL default 'passive'
568 SHOW CREATE TABLE t2;
569 ALTER TABLE t2 ADD a int NOT NULL AFTER status; 
571 DROP TABLE t1,t2;
574 # Some broken functions:  add these tests just to document current behavior.
576 # PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
577 # not be backwards compatible in all cases, so it's best to leave it alone
578 select password(name) from bug20536;
579 select old_password(name) from bug20536;
581 # Disable test case as encrypt relies on 'crypt' function.
582 # "decrypt" is noramlly tested in func_crypt.test which have a
583 # "have_crypt.inc" test
584 --disable_parsing
585 # ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it
586 # doesn't return good results for strings with embedded 0 bytes.  It won't be
587 # fixed unless we choose to re-implement the crypt() function ourselves to take
588 # an extra size_t string_length argument.
589 select encrypt(name, 'SALT') from bug20536;
590 --enable_parsing
592 # QUOTE doesn't work with UCS2 data.  It would require a total rewrite
593 # of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
594 # supported fully as a client character set.
595 select quote(name) from bug20536;
597 drop table bug20536;
600 # Bug #31615: crash after set names ucs2 collate xxx
602 --error 1231
603 set names ucs2;
604 --error 1231
605 set names ucs2 collate ucs2_bin;
606 --error 1231
607 set character_set_client= ucs2;
608 --error 1231
609 set character_set_client= concat('ucs', substr('2', 1));
612 # BUG#31159 - fulltext search on ucs2 column crashes server
614 CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci);
615 INSERT INTO t1 VALUES('abcd');
616 SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE);
617 DROP TABLE t1;
619 --echo End of 4.1 tests
622 # Conversion from an UCS2 string to a decimal column
624 CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
625 INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
626 update t1 set b=a;
627 SELECT * FROM t1;
628 DROP TABLE t1;
631 # Bug#9442 Set parameter make query fail if column character set is UCS2
633 create table t1 (utext varchar(20) character set ucs2);
634 insert into t1 values ("lily");
635 insert into t1 values ("river");
636 prepare stmt from 'select utext from t1 where utext like ?';
637 set @param1='%%';
638 execute stmt using @param1;
639 execute stmt using @param1;
640 select utext from t1 where utext like '%%';
641 drop table t1;
642 deallocate prepare stmt;
645 # Bug#22638 SOUNDEX broken for international characters
647 set names latin1;
648 set character_set_connection=ucs2;
649 select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
650 select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb'));
651 select 'mood' sounds like 'mud';
652 # Cyrillic A, BE, VE
653 select hex(soundex(_ucs2 0x041004110412));
654 # Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
655 select hex(soundex(_ucs2 0x00BF00C0));
656 set names latin1;
659 # Bug #14290: character_maximum_length for text fields
661 create table t1(a blob, b text charset utf8, c text charset ucs2);
662 select data_type, character_octet_length, character_maximum_length
663   from information_schema.columns where table_name='t1';
664 drop table t1;
667 # Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
669 create table t1 (a char(1) character set ucs2);
670 insert into t1 values ('a'),('b'),('c');
671 select hex(group_concat(a)) from t1;
672 select collation(group_concat(a)) from t1;
673 drop table t1;
675 set names latin1;
676 create table t1 (a char(1) character set latin1);
677 insert into t1 values ('a'),('b'),('c');
678 set character_set_connection=ucs2;
679 select hex(group_concat(a separator ',')) from t1;
680 select collation(group_concat(a separator ',')) from t1;
681 drop table t1;
682 set names latin1;
685 # Bug#29499 Converting 'del' from ascii to Unicode results in 'question mark'
687 create table t1 (s1 char(1) character set ascii, s2 char(1) character set ucs2);
688 insert into t1 (s1) values (0x7f);
689 update t1 set s2 = s1;
690 select hex(s2) from t1;
691 select hex(convert(s1 using latin1)) from t1;
692 drop table t1;
695 # Conversion from UCS2 to ASCII is possible
696 # if the UCS2 string consists of only ASCII characters
698 create table t1 (a varchar(15) character set ascii not null, b int);
699 insert into t1 values ('a',1);
700 select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
701 select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
702 select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062);
703 select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062);
706 # Conversion from UCS2 to ASCII is not possible if 
707 # the UCS2 string has non-ASCII characters
709 --error 1267
710 select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
711 --error 1267
712 select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
713 --error 1267
714 select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
715 --error 1267
716 select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
717 --error 1267
718 select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062);
719 --error 1267
720 select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
721 drop table t1;
724 # Bug#35720 ucs2 + pad_char_to_full_length = failure
726 CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2);
727 INSERT INTO t1 VALUES ('a');
728 SET @@sql_mode=pad_char_to_full_length;
729 SELECT HEX(s1) FROM t1;
730 SET @@sql_mode=default;
731 SELECT HEX(s1) FROM t1;
732 DROP TABLE t1;
734 set collation_connection=ucs2_general_ci;
735 --source include/ctype_regex.inc
736 set names latin1;
738 # Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero
740 select hex(char(0x41 using ucs2));
743 # Bug#37575: UCASE fails on monthname
745 SET character_set_connection=ucs2;
746 SELECT CHARSET(DAYNAME(19700101));
747 SELECT CHARSET(MONTHNAME(19700101));
748 SELECT LOWER(DAYNAME(19700101));
749 SELECT LOWER(MONTHNAME(19700101));
750 SELECT UPPER(DAYNAME(19700101));
751 SELECT UPPER(MONTHNAME(19700101));
752 SELECT HEX(MONTHNAME(19700101));
753 SELECT HEX(DAYNAME(19700101));
754 SET LC_TIME_NAMES=ru_RU;
755 SET NAMES utf8;
756 SET character_set_connection=ucs2;
757 SELECT CHARSET(DAYNAME(19700101));
758 SELECT CHARSET(MONTHNAME(19700101));
759 SELECT LOWER(DAYNAME(19700101));
760 SELECT LOWER(MONTHNAME(19700101));
761 SELECT UPPER(DAYNAME(19700101));
762 SELECT UPPER(MONTHNAME(19700101));
763 SELECT HEX(MONTHNAME(19700101));
764 SELECT HEX(DAYNAME(19700101));
765 SET character_set_connection=latin1;
767 --echo #
768 --echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
769 --echo #
770 CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1);
771 CREATE VIEW v1 AS SELECT 1 from t1
772 WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
773 DROP VIEW v1;
774 DROP TABLE t1;
776 --echo #
777 --echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
778 --echo #
779 SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850));
780 SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED);
782 --echo End of 5.0 tests