-- source include/have_latin2_ch.inc

#
# Tests with latin2_czech_cs
#
--disable_warnings
drop table if exists t1;
--enable_warnings

#
# Bug#17374: select ... like 'A%' operator fails
# to find value on columuns with key
#
set names latin2;
select 'A' = 'a' collate latin2_czech_cs;
create table t1 (
    id  int(5) not null,    
    tt  char(255) not null
) character set latin2 collate latin2_czech_cs;
insert into t1 values (1,'Aa');
insert into t1 values (2,'Aas');
alter table t1 add primary key aaa(tt); 
select * from t1 where tt like 'Aa%';
select * from t1 ignore index (primary) where tt like 'Aa%';
select * from t1 where tt like '%Aa%';
select * from t1 where tt like 'AA%';
select * from t1 ignore index (primary) where tt like 'AA%';
select * from t1 where tt like '%AA%';

drop table t1;

# End of 4.1 tests

set names latin2 collate latin2_czech_cs;
--source include/ctype_pad_space.inc

# We can not use ctype_filesort.inc because
# order of SPACE and TAB is not strict
#--source include/ctype_filesort.inc
#

#
# Bug#29459 server died handling latin2 collate latin2_czech_cs
#
create table t1 (
  a varchar(2) character set latin2 collate latin2_czech_cs,
  primary key(a)
);
insert into t1 set a=0x5ff;
insert into t1 set a=0xff;
select hex(a) from t1;
drop table t1;

#
# Bug#33452 Primary difference between capital and small letters U and O
#
create table t1 (
  ch varchar(1),
  name varchar(64)
) character set latin2 collate latin2_czech_cs;

insert into t1 values (0x6F,'LATIN SMALL LETTER O');
insert into t1 values (0xF3,'LATIN SMALL LETTER O WITH ACUTE');
insert into t1 values (0xF4,'LATIN SMALL LETTER O WITH CIRCUMFLEX');
insert into t1 values (0xF6,'LATIN SMALL LETTER O WITH DIAERESIS');
insert into t1 values (0xF5,'LATIN SMALL LETTER O WITH DOUBLE ACUTE');
insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');

insert into t1 values (0x75,'LATIN SMALL LETTER U');
insert into t1 values (0xFA,'LATIN SMALL LETTER U WITH ACUTE');
insert into t1 values (0xF9,'LATIN SMALL LETTER U WITH RING ABOVE');
insert into t1 values (0xFC,'LATIN SMALL LETTER U WITH DIAERESIS');
insert into t1 values (0xFB,'LATIN SMALL LETTER U WITH DOUBLE ACUTE');
insert into t1 values (0x55,'LATIN CAPITAL LETTER U');
insert into t1 values (0xDA,'LATIN CAPITAL LETTER U WITH ACUTE');
insert into t1 values (0xD9,'LATIN CAPITAL LETTER U WITH RING ABOVE');
insert into t1 values (0xDC,'LATIN CAPITAL LETTER U WITH DIAERESIS');
insert into t1 values (0xDB,'LATIN CAPITAL LETTER U WITH DOUBLE ACUTE');
select
hex(weight_string(ch level 1)) l1,
hex(weight_string(ch level 2)) l2,
hex(weight_string(ch level 3)) l3,
hex(weight_string(ch level 4)) l4,
name from t1 order by binary l1, binary l2, binary l3, binary l4;
drop table t1;

#
# Bug#33791 Wrong ORDER BY with latin2_czech_cs
#
set names utf8;
create table t1 (
ch varchar(1),
name varchar(64)
) character set latin2 collate latin2_czech_cs;
insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');
insert into t1 values (0x75,'LATIN _SMALL_ LETTER U');
insert into t1 values (0xFA,'LATIN _SMALL_ LETTER U WITH ACUTE');
insert into t1 values (0xF9,'LATIN _SMALL_ LETTER U WITH RING ABOVE');
insert into t1 values (0xFC,'LATIN _SMALL_ LETTER U WITH DIAERESIS');
insert into t1 values (0xFB,'LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE');
# Testing order by Field_varchar
select ch,
  hex(weight_string(ch level 1)) l1,
  hex(weight_string(ch level 2)) l2,
  hex(weight_string(ch level 3)) l3,
  hex(weight_string(ch level 4)) l4,
  name from t1 order by ch;
alter table t1 modify ch char(1), modify name char(64);
# Testing order by Field_char
select ch,
  hex(weight_string(ch level 1)) l1,
  hex(weight_string(ch level 2)) l2,
  hex(weight_string(ch level 3)) l3,
  hex(weight_string(ch level 4)) l4,
  name from t1 order by ch;
# Testing order by Item
select ch,
  hex(weight_string(ch level 1)) l1,
  hex(weight_string(ch level 2)) l2,
  hex(weight_string(ch level 3)) l3,
  hex(weight_string(ch level 4)) l4,
  name from t1 order by concat(ch);
drop table t1;

#
# Bug #30462 Character sets: search failures with case sensitive collations
#
SET collation_connection=latin2_czech_cs;
CREATE TABLE t1 ENGINE=MYISAM AS SELECT repeat('a', 5) AS s1 LIMIT 0;
INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
CREATE INDEX i1 ON t1 (s1);
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;

--disable_warnings
CREATE TABLE t1 ENGINE=INNODB AS SELECT repeat('a', 5) AS s1 LIMIT 0;
--enable_warnings
INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
CREATE INDEX i1 ON t1 (s1);
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;

--disable_warnings
SET sql_mode='';
CREATE TABLE t1 ENGINE=FALCON AS SELECT repeat('a', 5) AS s1 LIMIT 0;
SET sql_mode=DEFAULT;
--enable_warnings
INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
CREATE INDEX i1 ON t1 (s1);
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;

--disable_warnings
SET sql_mode='';
CREATE TABLE t1 ENGINE=MARIA AS SELECT repeat('a', 5) AS s1 LIMIT 0;
SET sql_mode=DEFAULT;
--enable_warnings
INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
CREATE INDEX i1 ON t1 (s1);
SELECT * FROM t1 GROUP BY s1;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;

SET NAMES latin2;

#
# Bug#37854 Test fails/aborts for collate latin2_czech_cs used with SET and ENUM datatypes
#
CREATE TABLE t2(colours SET('red','blue','yellow'))CHARACTER SET latin2 COLLATE
latin2_czech_cs;
CREATE TABLE t1(continent ENUM('Asia', 'Europe','Africa','Antartica'))CHARACTER SET latin2
COLLATE latin2_czech_cs;
INSERT INTO t1 VALUES('Asia');
INSERT INTO t2 VALUES('blue');
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;

#
# Bug#40805 Cannot restore table
#
CREATE TABLE `t1` (
  `ID` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
  `Post` enum('','B','O','Z','U') COLLATE latin2_czech_cs DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=135 DEFAULT CHARSET=latin2;
SHOW CREATE TABLE t1;
INSERT INTO t1 (ID,Post) VALUES (00041,'');
SELECT ID, Post, HEX(WEIGHT_STRING(Post)) FROM t1;
DROP TABLE t1;


--echo #
--echo # Start of 5.6 tests
--echo #

--echo #
--echo # WL#3664 WEIGHT_STRING
--echo #

set names latin2 collate latin2_czech_cs;
--source include/ctype_pad_space.inc
# We can not use ctype_filesort.inc because
# order of SPACE and TAB is not strict
#--source include/ctype_filesort.inc

--echo #
--echo # Note:
--echo # latin2_czech_cs does not support WEIGHT_STRING in full extent
--echo #
--source include/weight_string.inc
--source include/weight_string_chde.inc
--source include/weight_string_l1.inc
--source include/weight_string_l2.inc
--source include/weight_string_l3.inc
--source include/weight_string_l4.inc
--source include/weight_string_l12.inc
--source include/weight_string_l14.inc

--echo #
--echo # End of 5.6 tests
--echo #

