1--source include/no_valgrind_without_big.inc
2
3--disable_warnings
4DROP TABLE IF EXISTS t1;
5--enable_warnings
6
7SET @test_character_set= 'ucs2';
8SET @test_collation= 'ucs2_general_ci';
9-- source include/ctype_common.inc
10
11# Ordering below is important, since 'SET CHARACTER SET' implicitly sets
12# character_set_connection to character_set_database.
13SET NAMES latin1;
14SET CHARACTER SET koi8r;
15SET character_set_connection=ucs2;
16-- source include/endspace.inc
17
18#
19# BUG#49028, error in LIKE with ucs2
20#
21create table t1 (a varchar(2) character set ucs2 collate ucs2_bin, key(a));
22insert into t1 values ('A'),('A'),('B'),('C'),('D'),('A\t');
23insert into t1 values ('A\0'),('A\0'),('A\0'),('A\0'),('AZ');
24select hex(a) from t1 where a like 'A_' order by a;
25select hex(a) from t1 ignore key(a) where a like 'A_' order by a;
26drop table t1;
27
28#
29# Check that 0x20 is only trimmed when it is
30# a part of real SPACE character, not just a part
31# of a multibyte sequence.
32# Note, CYRILLIC LETTER ER is used as an example, which
33# is stored as 0x0420 in UCS2, thus contains 0x20 in the
34# low byte. The second character is THREE-PER-M, U+2004,
35# which contains 0x20 in the high byte.
36#
37
38CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2, word2 CHAR(64) CHARACTER SET ucs2);
39INSERT INTO t1 VALUES (_koi8r'�',_koi8r'�'), (X'2004',X'2004');
40SELECT hex(word) FROM t1 ORDER BY word;
41SELECT hex(word2) FROM t1 ORDER BY word2;
42DELETE FROM t1;
43
44#
45# Check that real spaces are correctly trimmed.
46#
47
48INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020');
49SELECT hex(word) FROM t1 ORDER BY word;
50SELECT hex(word2) FROM t1 ORDER BY word2;
51DROP TABLE t1;
52
53#
54# Check LPAD/RPAD
55#
56SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'0421');
57SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
58SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
59SELECT LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
60
61SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'0421');
62SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
63SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
64SELECT RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
65
66CREATE TABLE t1 SELECT
67LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l,
68RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r;
69SHOW CREATE TABLE t1;
70DROP TABLE t1;
71
72--echo #
73--echo # Bug #51876 : crash/memory underrun when loading data with ucs2
74--echo #   and reverse() function
75--echo #
76
77--echo # Problem # 1 (original report): wrong parsing of ucs2 data
78SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt';
79CREATE TABLE t1(a INT);
80LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2
81(@b) SET a=REVERSE(@b);
82--echo # should return 2 zeroes (as the value is truncated)
83SELECT * FROM t1;
84
85DROP TABLE t1;
86let $MYSQLD_DATADIR= `select @@datadir`;
87remove_file $MYSQLD_DATADIR/test/tmpp.txt;
88
89
90--echo # Problem # 2 : if you write and read ucs2 data to a file they're lost
91SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2;
92CREATE TABLE t1(a INT);
93LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2
94(@b) SET a=REVERSE(@b);
95--echo # should return 0 and 1 (10 reversed)
96SELECT * FROM t1;
97
98DROP TABLE t1;
99let $MYSQLD_DATADIR= `select @@datadir`;
100remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
101
102
103
104#
105# BUG3946
106#
107
108create table t2(f1 Char(30));
109insert into t2 values ("103000"), ("22720000"), ("3401200"), ("78000");
110select lpad(f1, 12, "-o-/") from t2;
111drop table t2;
112
113######################################################
114#
115# Test of like
116#
117
118SET NAMES koi8r;
119SET character_set_connection=ucs2;
120--source include/ctype_like.inc
121--character_set koi8r
122CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
123INSERT INTO t1 VALUES ('����'),('����'),('����'),('����'),('����'),('����');
124INSERT INTO t1 VALUES ('����������'),('����������'),('����������'),('����������');
125INSERT INTO t1 VALUES ('����������'),('����������'),('����������'),('����������');
126INSERT INTO t1 VALUES ('����������'),('����������'),('����������'),('����������');
127SELECT * FROM t1 WHERE a LIKE '%����%';
128SELECT * FROM t1 WHERE a LIKE '%���%';
129SELECT * FROM t1 WHERE a LIKE '����%';
130SELECT * FROM t1 WHERE a LIKE '����%' COLLATE ucs2_bin;
131DROP TABLE t1;
132--character_set utf8mb4
133
134#
135# Check that INSERT works fine.
136# This invokes charpos() function.
137select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066);
138select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066);
139
140######################################################
141
142# Bug #2390
143# Check alignment for constants
144#
145SELECT HEX(_ucs2 0x0);
146SELECT HEX(_ucs2 0x01);
147SELECT HEX(_ucs2 0x012);
148SELECT HEX(_ucs2 0x0123);
149SELECT HEX(_ucs2 0x01234);
150SELECT HEX(_ucs2 0x012345);
151SELECT HEX(_ucs2 0x0123456);
152SELECT HEX(_ucs2 0x01234567);
153SELECT HEX(_ucs2 0x012345678);
154SELECT HEX(_ucs2 0x0123456789);
155SELECT HEX(_ucs2 0x0123456789A);
156SELECT HEX(_ucs2 0x0123456789AB);
157SELECT HEX(_ucs2 0x0123456789ABC);
158SELECT HEX(_ucs2 0x0123456789ABCD);
159SELECT HEX(_ucs2 0x0123456789ABCDE);
160SELECT HEX(_ucs2 0x0123456789ABCDEF);
161
162#
163# Check alignment for from-binary-conversion with CAST and CONVERT
164#
165SELECT hex(cast(0xAA as char character set ucs2));
166SELECT hex(convert(0xAA using ucs2));
167
168#
169# Check alignment for string types
170#
171CREATE TABLE t1 (a char(10) character set ucs2);
172INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
173SELECT HEX(a) FROM t1;
174DROP TABLE t1;
175
176CREATE TABLE t1 (a varchar(10) character set ucs2);
177INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
178SELECT HEX(a) FROM t1;
179DROP TABLE t1;
180
181CREATE TABLE t1 (a text character set ucs2);
182INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
183SELECT HEX(a) FROM t1;
184DROP TABLE t1;
185
186CREATE TABLE t1 (a mediumtext character set ucs2);
187INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
188SELECT HEX(a) FROM t1;
189DROP TABLE t1;
190
191CREATE TABLE t1 (a longtext character set ucs2);
192INSERT INTO t1 VALUES (0xA),(0xAA),(0xAAA),(0xAAAA),(0xAAAAA);
193SELECT HEX(a) FROM t1;
194DROP TABLE t1;
195
196# the same should be also done with enum and set
197
198
199#
200# Bug #5024 Server crashes with queries on fields
201#  with certain charset/collation settings
202#
203
204create table t1 (s1 char character set `ucs2` collate `ucs2_czech_ci`);
205insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c');
206select s1 from t1 where s1 > 'a' order by s1;
207drop table t1;
208
209#
210# Bug #5081 : UCS2 fields are filled with '0x2020'
211# after extending field length
212#
213create table t1(a char(1)) default charset = ucs2;
214insert into t1 values ('a'),('b'),('c');
215alter table t1 modify a char(5);
216select a, hex(a) from t1;
217drop table t1;
218
219#
220# Check prepare statement from an UCS2 string
221#
222set names latin1;
223set @ivar= 1234;
224set @str1 = 'select ?';
225set @str2 = convert(@str1 using ucs2);
226prepare stmt1 from @str2;
227execute stmt1 using @ivar;
228
229#
230# Check that ucs2 works with ENUM and SET type
231#
232set names latin1;
233--character_set latin1
234create table t1 (a enum('x','y','z') character set ucs2);
235show create table t1;
236insert into t1 values ('x');
237insert into t1 values ('y');
238insert into t1 values ('z');
239select a, hex(a) from t1 order by a;
240alter table t1 change a a enum('x','y','z','d','e','�','�','�') character set ucs2;
241show create table t1;
242insert into t1 values ('D');
243insert into t1 values ('E ');
244insert into t1 values ('�');
245insert into t1 values ('�');
246insert into t1 values ('�');
247select a, hex(a) from t1 order by a;
248drop table t1;
249
250create table t1 (a set ('x','y','z','�','�','�') character set ucs2);
251show create table t1;
252insert into t1 values ('x');
253insert into t1 values ('y');
254insert into t1 values ('z');
255insert into t1 values ('x,y');
256insert into t1 values ('x,y,z,�,�,�');
257select a, hex(a) from t1 order by a;
258drop table t1;
259--character_set utf8mb4
260
261#
262# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
263#
264create table t1(a enum('a','b','c')) default character set ucs2;
265insert into t1 values('a'),('b'),('c');
266alter table t1 add b char(1);
267show warnings;
268select * from t1 order by a;
269drop table t1;
270
271SET collation_connection='ucs2_general_ci';
272-- source include/ctype_filesort.inc
273-- source include/ctype_like_escape.inc
274-- source include/ctype_german.inc
275-- source include/ctype_like_range_f1f2.inc
276SET NAMES latin1;
277SET collation_connection='ucs2_bin';
278-- source include/ctype_filesort.inc
279-- source include/ctype_like_escape.inc
280-- source include/ctype_like_range_f1f2.inc
281
282#
283# Bug#10344 Some string functions fail for UCS2
284#
285select hex(substr(_ucs2 0x00e400e50068,1));
286select hex(substr(_ucs2 0x00e400e50068,2));
287select hex(substr(_ucs2 0x00e400e50068,3));
288select hex(substr(_ucs2 0x00e400e50068,-1));
289select hex(substr(_ucs2 0x00e400e50068,-2));
290select hex(substr(_ucs2 0x00e400e50068,-3));
291
292SET NAMES latin1;
293#
294# Bug#8235
295#
296# This bug also helped to find another problem that
297# INSERT of a UCS2 string containing a negative number
298# into a unsigned int column didn't produce warnings.
299# This test covers both problems.
300#
301SET collation_connection='ucs2_swedish_ci';
302CREATE TABLE t1 (Field1 int(10) default '0');
303# no warnings, negative numbers are allowed
304INSERT INTO t1 VALUES ('-1');
305SELECT * FROM t1;
306DROP TABLE t1;
307CREATE TABLE t1 (Field1 int(10) unsigned default '0');
308# this should generate a "Data truncated" warning
309INSERT IGNORE INTO t1 VALUES ('-1');
310DROP TABLE t1;
311SET NAMES latin1;
312
313#
314# Bug#18691 Converting number to UNICODE string returns invalid result
315#
316SELECT CONVERT(103, CHAR(50) UNICODE);
317SELECT CONVERT(103.0, CHAR(50) UNICODE);
318SELECT CONVERT(-103, CHAR(50) UNICODE);
319SELECT CONVERT(-103.0, CHAR(50) UNICODE);
320
321#
322# Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation
323#
324--disable_warnings
325create table t1(f1 varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL) engine=InnoDB;
326--enable_warnings
327insert into t1 values('a');
328create index t1f1 on t1(f1);
329select f1 from t1 where f1 like 'a%';
330drop table t1;
331
332#
333# Bug#9442 Set parameter make query fail if column character set is UCS2
334#
335create table t1 (utext varchar(20) character set ucs2);
336insert into t1 values ("lily");
337insert into t1 values ("river");
338prepare stmt from 'select utext from t1 where utext like ?';
339set @param1='%%';
340execute stmt using @param1;
341execute stmt using @param1;
342select utext from t1 where utext like '%%';
343drop table t1;
344deallocate prepare stmt;
345
346#
347# Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
348#             over a 'ucs2' field uses a temporary table
349#
350
351CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
352INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
353
354SELECT id, MIN(s) FROM t1 GROUP BY id;
355
356DROP TABLE t1;
357
358#
359# Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
360#
361
362--disable_warnings
363drop table if exists bug20536;
364--enable_warnings
365
366set names latin1;
367create table bug20536 (id bigint not null auto_increment primary key, name
368varchar(255) character set ucs2 not null);
369insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
370select md5(name) from bug20536;
371select sha1(name) from bug20536;
372select make_set(3, name, upper(name)) from bug20536;
373select export_set(5, name, upper(name)) from bug20536;
374select export_set(5, name, upper(name), ",", 5) from bug20536;
375
376#
377# Bug #20108: corrupted default enum value for a ucs2 field
378#
379
380CREATE TABLE t1 (
381  status enum('active','passive') collate latin1_general_ci
382    NOT NULL default 'passive'
383);
384SHOW CREATE TABLE t1;
385ALTER TABLE t1 ADD a int NOT NULL AFTER status;
386
387CREATE TABLE t2 (
388  status enum('active','passive') collate ucs2_turkish_ci
389    NOT NULL default 'passive'
390);
391SHOW CREATE TABLE t2;
392ALTER TABLE t2 ADD a int NOT NULL AFTER status;
393
394DROP TABLE t1,t2;
395
396
397# Some broken functions:  add these tests just to document current behavior.
398
399# PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
400# not be backwards compatible in all cases, so it's best to leave it alone
401# 2011-11-08 update: change in behavior caused by refactoring of
402#   Item_func_password() but since the below test doesn't show correct behavior
403#   anyway it is removed.
404# select password(name) from bug20536;
405# select old_password(name) from bug20536;
406
407# QUOTE doesn't work with UCS2 data.  It would require a total rewrite
408# of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
409# supported fully as a client character set.
410select quote(name) from bug20536;
411
412drop table bug20536;
413
414#
415# Bug #31615: crash after set names ucs2 collate xxx
416#
417--error 1231
418set names ucs2;
419--error 1231
420set names ucs2 collate ucs2_bin;
421--error 1231
422set character_set_client= ucs2;
423--error 1231
424set character_set_client= concat('ucs', substr('2', 1));
425
426--echo End of 4.1 tests
427
428#
429# Conversion from an UCS2 string to a decimal column
430#
431CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
432INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
433update t1 set b=a;
434SELECT * FROM t1;
435DROP TABLE t1;
436
437#
438# Bug#9442 Set parameter make query fail if column character set is UCS2
439#
440create table t1 (utext varchar(20) character set ucs2);
441insert into t1 values ("lily");
442insert into t1 values ("river");
443prepare stmt from 'select utext from t1 where utext like ?';
444set @param1='%%';
445execute stmt using @param1;
446execute stmt using @param1;
447select utext from t1 where utext like '%%';
448drop table t1;
449deallocate prepare stmt;
450
451#
452# Bug#22638 SOUNDEX broken for international characters
453#
454set names latin1;
455set character_set_connection=ucs2;
456select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
457select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb'));
458select 'mood' sounds like 'mud';
459# Cyrillic A, BE, VE
460select hex(soundex(_ucs2 0x041004110412));
461# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
462select hex(soundex(_ucs2 0x00BF00C0));
463set names latin1;
464
465#
466# Bug #14290: character_maximum_length for text fields
467#
468create table t1(a blob, b text charset utf8, c text charset ucs2);
469select data_type, character_octet_length, character_maximum_length
470  from information_schema.columns where table_name='t1';
471drop table t1;
472
473#
474# Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
475#
476create table t1 (a char(1) character set ucs2);
477insert into t1 values ('a'),('b'),('c');
478select hex(group_concat(a)) from t1;
479select collation(group_concat(a)) from t1;
480drop table t1;
481
482set names latin1;
483create table t1 (a char(1) character set latin1);
484insert into t1 values ('a'),('b'),('c');
485set character_set_connection=ucs2;
486select hex(group_concat(a separator ',')) from t1;
487select collation(group_concat(a separator ',')) from t1;
488drop table t1;
489set names latin1;
490
491#
492# Bug#29499 Converting 'del' from ascii to Unicode results in 'question mark'
493#
494create table t1 (s1 char(1) character set ascii, s2 char(1) character set ucs2);
495insert into t1 (s1) values (0x7f);
496update t1 set s2 = s1;
497select hex(s2) from t1;
498select hex(convert(s1 using latin1)) from t1;
499drop table t1;
500
501#
502# Conversion from UCS2 to ASCII is possible
503# if the UCS2 string consists of only ASCII characters
504#
505create table t1 (a varchar(15) character set ascii not null, b int);
506insert into t1 values ('a',1);
507select concat(a,if(b<10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
508select concat(a,if(b>10,_ucs2 0x0061,_ucs2 0x0062)) from t1;
509select * from t1 where a=if(b<10,_ucs2 0x0061,_ucs2 0x0062);
510select * from t1 where a=if(b>10,_ucs2 0x0061,_ucs2 0x0062);
511
512#
513# Conversion from UCS2 to ASCII is not possible if
514# the UCS2 string has non-ASCII characters
515#
516--error 1267
517select concat(a,if(b<10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
518--error 1267
519select concat(a,if(b>10,_ucs2 0x00C0,_ucs2 0x0062)) from t1;
520--error 1267
521select concat(a,if(b<10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
522--error 1267
523select concat(a,if(b>10,_ucs2 0x0062,_ucs2 0x00C0)) from t1;
524--error 1267
525select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062);
526--error 1267
527select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0);
528drop table t1;
529
530#
531# Bug#35720 ucs2 + pad_char_to_full_length = failure
532#
533CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET UCS2);
534INSERT INTO t1 VALUES ('a');
535SET @@sql_mode=pad_char_to_full_length;
536SELECT HEX(s1) FROM t1;
537SET @@sql_mode=default;
538SELECT HEX(s1) FROM t1;
539DROP TABLE t1;
540
541set collation_connection=ucs2_general_ci;
542--source include/ctype_regex.inc
543set names latin1;
544#
545# Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero
546#
547select hex(char(0x41 using ucs2));
548
549#
550# Bug#37575: UCASE fails on monthname
551#
552SET character_set_connection=ucs2;
553SELECT CHARSET(DAYNAME(19700101));
554SELECT CHARSET(MONTHNAME(19700101));
555SELECT LOWER(DAYNAME(19700101));
556SELECT LOWER(MONTHNAME(19700101));
557SELECT UPPER(DAYNAME(19700101));
558SELECT UPPER(MONTHNAME(19700101));
559SELECT HEX(MONTHNAME(19700101));
560SELECT HEX(DAYNAME(19700101));
561SET LC_TIME_NAMES=ru_RU;
562SET NAMES utf8;
563SET character_set_connection=ucs2;
564SELECT CHARSET(DAYNAME(19700101));
565SELECT CHARSET(MONTHNAME(19700101));
566SELECT LOWER(DAYNAME(19700101));
567SELECT LOWER(MONTHNAME(19700101));
568SELECT UPPER(DAYNAME(19700101));
569SELECT UPPER(MONTHNAME(19700101));
570SELECT HEX(MONTHNAME(19700101));
571SELECT HEX(DAYNAME(19700101));
572SET character_set_connection=latin1;
573
574--echo #
575--echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
576--echo #
577CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1);
578CREATE VIEW v1 AS SELECT 1 from t1
579WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
580DROP VIEW v1;
581DROP TABLE t1;
582
583--echo #
584--echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
585--echo #
586SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850));
587SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED);
588
589--echo End of 5.0 tests
590
591
592--echo #
593--echo # Start of 5.5 tests
594--echo #
595
596SET NAMES latin1;
597SET collation_connection=ucs2_general_ci;
598--source include/ctype_numconv.inc
599SET NAMES latin1;
600
601--echo #
602--echo # Bug #13832953 	MY_STRNXFRM_UNICODE: ASSERTION `SRC' FAILED
603--echo #
604SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
605CREATE TABLE t1 (c1 SET('','') CHARACTER SET ucs2);
606INSERT INTO t1 VALUES ('');
607SELECT COALESCE(c1) FROM t1 ORDER BY 1;
608DROP TABLE t1;
609SET sql_mode = default;
610
611--echo #
612--echo # End of 5.5 tests
613--echo #
614
615
616--echo #
617--echo # Start of 5.6 tests
618--echo #
619
620--echo #
621--echo # WL#3664 WEIGHT_STRING
622--echo #
623
624set collation_connection=ucs2_general_ci;
625--source include/weight_string.inc
626--source include/weight_string_euro.inc
627
628set collation_connection=ucs2_bin;
629--source include/weight_string.inc
630--source include/weight_string_euro.inc
631
632--echo #
633--echo # Bug #36418 Character sets: crash if char(256 using utf32)
634--echo #
635select hex(char(0x01 using ucs2));
636select hex(char(0x0102 using ucs2));
637select hex(char(0x010203 using ucs2));
638select hex(char(0x01020304 using ucs2));
639
640--echo #
641--echo # Bug#10094 Displays wrong error message for UNIQUE key index on CHAR(255) Unicode datatype
642--echo #
643CREATE TABLE t1 (f1 CHAR(255) unicode);
644INSERT INTO t1 values ('abc'),('bcd'),('abc');
645--error ER_DUP_ENTRY
646ALTER TABLE t1 ADD UNIQUE Index_1 (f1);
647DROP TABLE t1;
648
649--echo #
650--echo # Test how character set works with date/time
651--echo #
652SET collation_connection=ucs2_general_ci;
653--source include/ctype_datetime.inc
654SET NAMES latin1;
655
656--echo #
657--echo # WL#4013 Unicode german2 collation
658--echo #
659SET collation_connection=ucs2_german2_ci;
660--source include/ctype_german.inc
661
662--echo #
663--echo # Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2
664--echo #
665SET NAMES latin1;
666SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED);
667DO IFNULL(CHAR(NULL USING ucs2), '');
668DO CAST(CONVERT('' USING ucs2) AS UNSIGNED);
669
670--echo #
671--echo # Test error message for conversion using different charset
672--echo #
673
674CREATE TABLE t1 (a DECIMAL(2,0));
675
676SET sql_mode=default;
677--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
678INSERT INTO t1 VALUES (CONVERT('9e99999999' USING ucs2));
679
680INSERT IGNORE INTO t1 VALUES (CONVERT('aaa' USING ucs2));
681
682DROP TABLE t1;
683
684--echo #
685--echo # End of 5.6 tests
686--echo #
687
688--echo #
689--echo # Bug#27419181 UBSAN: MY_STRNTOLL_MB2_OR_MB4 - NAUGHTY NEGATIVES
690--echo #
691
692SELECT CONVERT('-9223372036854775808' USING utf16le) & 0;
693SELECT CONVERT('-9223372036854775808' USING utf8mb4) & 0;
694
695--echo #
696--echo # Bug#29585648: UBSAN NEGATION OF NEGATIVE IN MY_STRTOLL10_MB2
697--echo #
698SELECT CAST(CONVERT("-9223372036854775808" USING utf16le) AS SIGNED);
699SELECT CAST(CONVERT("-9223372036854775807" USING utf16le) AS SIGNED);
700
701SELECT CAST(CONVERT("-9223372036854775808" USING utf32) AS SIGNED);
702SELECT CAST(CONVERT("-9223372036854775807" USING utf32) AS SIGNED);
703