-- source include/have_innodb.inc
-- source include/have_bdb.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 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 = heap;
CREATE TABLE `Ｔ８` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = utf8 engine = heap;
CREATE TABLE `Ｔ９` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = utf8 engine = heap;
CREATE TABLE `Ｔ１０` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = utf8 engine = bdb;
CREATE TABLE `Ｔ１１` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = utf8 engine = bdb;
CREATE TABLE `Ｔ１２` (`Ｃ１` char(20), INDEX(`Ｃ１`)) DEFAULT CHARSET = utf8 engine = bdb;

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

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

#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 `Ｔ６`;

#Heap
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 `Ｔ９`;

#BDB
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 `Ｔ９`;
drop table `Ｔ１０`;
drop table `Ｔ１１`;
drop table `Ｔ１２`;
