--source include/have_sjis.inc
--source include/have_ucs2.inc
--source include/have_ujis.inc
--source include/have_utf8.inc
--source include/have_innodb.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 `Ｔ９`;
--enable_warnings

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

SET NAMES utf8;
SET character_set_database = utf8;

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

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

 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_utf8.dat' INTO TABLE `Ｔ１`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_utf8.dat' INTO TABLE `Ｔ２`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_utf8.dat' INTO TABLE `Ｔ３`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_utf8.dat' INTO TABLE `Ｔ４`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_utf8.dat' INTO TABLE `Ｔ５`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_utf8.dat' INTO TABLE `Ｔ６`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_utf8.dat' INTO TABLE `Ｔ７`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_utf8.dat' INTO TABLE `Ｔ８`;
 LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_utf8.dat' INTO TABLE `Ｔ９`;

#InnoDB
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ１`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ２`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) 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 ujis) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ４`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ５`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ６`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ６`;
# The result will get garbled because jisx0212 is not included in sjis
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ６`;

#MEMORY
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ７`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ucs2) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using sjis) FROM `Ｔ８`;
SELECT `Ｃ１`, CONVERT(`Ｃ１` using ujis) 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 `Ｔ９`;
