-- source include/have_innodb.inc
-- source include/have_bdb.inc
--source include/have_ucs2.inc

--disable_warnings
drop table if exists `Ｔ１`;
drop table if exists `Ｔ２`;
drop table if exists `Ｔ３`;
drop table if exists `Ｔ４`;
drop table if exists `Ｔ５`;
drop table if exists `Ｔ６`;
drop table if exists `Ｔ７`;
drop table if exists `Ｔ８`;
drop table if exists `Ｔ９`;
drop table if exists `Ｔ１０`;
drop table if exists `Ｔ１１`;
drop table if exists `Ｔ１２`;
--enable_warnings

#
# Test CONVERT() function with Japanese character in ucs2 encoding
#

SET NAMES ujis;
SET character_set_database = ucs2;
SET collation_connection = ucs2_general_ci;

CREATE TABLE `Ｔ１` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = innodb;
CREATE TABLE `Ｔ２` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = innodb;
CREATE TABLE `Ｔ３` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = innodb;
CREATE TABLE `Ｔ４` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = myisam;
CREATE TABLE `Ｔ５` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = myisam;
CREATE TABLE `Ｔ６` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = myisam;
CREATE TABLE `Ｔ７` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = heap;
CREATE TABLE `Ｔ８` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = heap;
CREATE TABLE `Ｔ９` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = heap;
CREATE TABLE `Ｔ１０` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = bdb;
CREATE TABLE `Ｔ１１` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = bdb;
CREATE TABLE `Ｔ１２` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = ucs2 engine = bdb;

#Insert the following data in each table
# jisx0201 hankaku-katakana data
# jisx0208 data
# jisx0212 supplemental character data

INSERT INTO `Ｔ１` VALUES
 ('PQRSTUVWXYZ[\\]^_')
,(' ｡｢｣､･ｦｧｨｩｪｫｬｭｮｯ')
,('ｰｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿ')
,('ﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏ')
,('ﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜﾝﾞﾟ');

INSERT INTO `Ｔ２` VALUES
 ('ヾゝゞ〃仝々〆〇ー―‐／＼〜‖｜…‥‘’')
,('“”（）〔〕［］｛｝〈〉《》「」『』【】')
,('・ぁあぃいぅうぇえぉおかがきぎくぐけげこ')
,('・ァアィイゥウェエォオカガキギクグケゲコ')
,('・亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵')
,('・弌丐丕个丱丶丼丿乂乖乘亂亅豫亊舒弍于亞')
,('・鵝鵞鵤鵑鵐鵙鵲鶉鶇鶫鵯鵺鶚鶤鶩鶲鷄鷁鶻');

INSERT INTO `Ｔ３` VALUES
 ('・˛˚~΄΅・・・・・・・・¡¦¿・・・')
,('乚乜乣乨乩乴乵乹乿亍亖亗亝亯亹仃仐仚仛仠')
,('仡仢仨仯仱仳仵份仾仿伀伂伃伈伋伌伒伕伖众')
,('伙伮伱你伳伵伷伹伻伾佀佂佈佉佋佌佒佔佖佘')
,('・黸黿鼂鼃鼉鼏鼐鼑鼒鼔鼖鼗鼙鼚鼛鼟鼢鼦鼪')
,('鼫鼯鼱鼲鼴鼷鼹鼺鼼鼽鼿齁齃齄齅齆齇齓齕齖')
,('齗齘齚齝齞齨齩齭齮齯齰齱齳齵齺齽龏龐龑龒');

INSERT INTO `Ｔ４` VALUES
 ('PQRSTUVWXYZ[\\]^_')
,(' ｡｢｣､･ｦｧｨｩｪｫｬｭｮｯ')
,('ｰｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿ')
,('ﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏ')
,('ﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜﾝﾞﾟ');

INSERT INTO `Ｔ５` VALUES
 ('ヾゝゞ〃仝々〆〇ー―‐／＼〜‖｜…‥‘’')
,('“”（）〔〕［］｛｝〈〉《》「」『』【】')
,('・ぁあぃいぅうぇえぉおかがきぎくぐけげこ')
,('・ァアィイゥウェエォオカガキギクグケゲコ')
,('・亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵')
,('・弌丐丕个丱丶丼丿乂乖乘亂亅豫亊舒弍于亞')
,('・鵝鵞鵤鵑鵐鵙鵲鶉鶇鶫鵯鵺鶚鶤鶩鶲鷄鷁鶻');

INSERT INTO `Ｔ６` VALUES
 ('・˛˚~΄΅・・・・・・・・¡¦¿・・・')
,('乚乜乣乨乩乴乵乹乿亍亖亗亝亯亹仃仐仚仛仠')
,('仡仢仨仯仱仳仵份仾仿伀伂伃伈伋伌伒伕伖众')
,('伙伮伱你伳伵伷伹伻伾佀佂佈佉佋佌佒佔佖佘')
,('・黸黿鼂鼃鼉鼏鼐鼑鼒鼔鼖鼗鼙鼚鼛鼟鼢鼦鼪')
,('鼫鼯鼱鼲鼴鼷鼹鼺鼼鼽鼿齁齃齄齅齆齇齓齕齖')
,('齗齘齚齝齞齨齩齭齮齯齰齱齳齵齺齽龏龐龑龒');

INSERT INTO `Ｔ７` VALUES
 ('PQRSTUVWXYZ[\\]^_')
,(' ｡｢｣､･ｦｧｨｩｪｫｬｭｮｯ')
,('ｰｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿ')
,('ﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏ')
,('ﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜﾝﾞﾟ');

INSERT INTO `Ｔ８` VALUES
 ('ヾゝゞ〃仝々〆〇ー―‐／＼〜‖｜…‥‘’')
,('“”（）〔〕［］｛｝〈〉《》「」『』【】')
,('・ぁあぃいぅうぇえぉおかがきぎくぐけげこ')
,('・ァアィイゥウェエォオカガキギクグケゲコ')
,('・亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵')
,('・弌丐丕个丱丶丼丿乂乖乘亂亅豫亊舒弍于亞')
,('・鵝鵞鵤鵑鵐鵙鵲鶉鶇鶫鵯鵺鶚鶤鶩鶲鷄鷁鶻');

INSERT INTO `Ｔ９` VALUES
 ('・˛˚~΄΅・・・・・・・・¡¦¿・・・')
,('乚乜乣乨乩乴乵乹乿亍亖亗亝亯亹仃仐仚仛仠')
,('仡仢仨仯仱仳仵份仾仿伀伂伃伈伋伌伒伕伖众')
,('伙伮伱你伳伵伷伹伻伾佀佂佈佉佋佌佒佔佖佘')
,('・黸黿鼂鼃鼉鼏鼐鼑鼒鼔鼖鼗鼙鼚鼛鼟鼢鼦鼪')
,('鼫鼯鼱鼲鼴鼷鼹鼺鼼鼽鼿齁齃齄齅齆齇齓齕齖')
,('齗齘齚齝齞齨齩齭齮齯齰齱齳齵齺齽龏龐龑龒');

INSERT INTO `Ｔ１０` VALUES
 ('PQRSTUVWXYZ[\\]^_')
,(' ｡｢｣､･ｦｧｨｩｪｫｬｭｮｯ')
,('ｰｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿ')
,('ﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏ')
,('ﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜﾝﾞﾟ');

INSERT INTO `Ｔ１１` VALUES
 ('ヾゝゞ〃仝々〆〇ー―‐／＼〜‖｜…‥‘’')
,('“”（）〔〕［］｛｝〈〉《》「」『』【】')
,('・ぁあぃいぅうぇえぉおかがきぎくぐけげこ')
,('・ァアィイゥウェエォオカガキギクグケゲコ')
,('・亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦鯵')
,('・弌丐丕个丱丶丼丿乂乖乘亂亅豫亊舒弍于亞')
,('・鵝鵞鵤鵑鵐鵙鵲鶉鶇鶫鵯鵺鶚鶤鶩鶲鷄鷁鶻');

INSERT INTO `Ｔ１２` VALUES
 ('・˛˚~΄΅・・・・・・・・¡¦¿・・・')
,('乚乜乣乨乩乴乵乹乿亍亖亗亝亯亹仃仐仚仛仠')
,('仡仢仨仯仱仳仵份仾仿伀伂伃伈伋伌伒伕伖众')
,('伙伮伱你伳伵伷伹伻伾佀佂佈佉佋佌佒佔佖佘')
,('・黸黿鼂鼃鼉鼏鼐鼑鼒鼔鼖鼗鼙鼚鼛鼟鼢鼦鼪')
,('鼫鼯鼱鼲鼴鼷鼹鼺鼼鼽鼿齁齃齄齅齆齇齓齕齖')
,('齗齘齚齝齞齨齩齭齮齯齰齱齳齵齺齽龏龐龑龒');

#InnoDB
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ３`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ３`;
# The result will get garbled because jisx0212 is not included in sjis
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ３`;

#MyISAM
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ６`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ６`;
# The result will get garbled because jisx0212 is not included in sjis
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ６`;

#Heap
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ９`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ９`;
# The result will get garbled because jisx0212 is not included in sjis
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ９`;

#BDB
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ１０`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ１０`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ１０`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ１１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ１１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ１１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using utf8) FROM `Ｔ１２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ１２`;
# The result will get garbled because jisx0212 is not included in sjis
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ１２`;

drop table `Ｔ１`;
drop table `Ｔ２`;
drop table `Ｔ３`;
drop table `Ｔ４`;
drop table `Ｔ５`;
drop table `Ｔ６`;
drop table `Ｔ７`;
drop table `Ｔ８`;
drop table `Ｔ９`;
drop table `Ｔ１０`;
drop table `Ｔ１１`;
drop table `Ｔ１２`;
