--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 subquery using Japanese characters in utf8 encoding
#

SET NAMES utf8;
SET character_set_database = utf8;

CREATE TABLE `Ｔ１a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ１b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ２a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ２b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ３a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ３b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
CREATE TABLE `Ｔ４a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ４b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ５a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ５b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ６a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ６b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
CREATE TABLE `Ｔ７a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
CREATE TABLE `Ｔ７b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
CREATE TABLE `Ｔ８a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
CREATE TABLE `Ｔ８b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
CREATE TABLE `Ｔ９a` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
CREATE TABLE `Ｔ９b` (`Ｃ１` char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;

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

INSERT INTO `Ｔ１a` VALUES ('ｱ'),('ｶ'),('ｻ');
INSERT INTO `Ｔ１b` VALUES ('ｱ');
INSERT INTO `Ｔ２a` VALUES ('あ'),('か'),('さ');
INSERT INTO `Ｔ２b` VALUES ('あ');
INSERT INTO `Ｔ３a` VALUES ('龔'),('龖'),('龗');
INSERT INTO `Ｔ３b` VALUES ('龔');
INSERT INTO `Ｔ４a` VALUES ('ｱ'),('ｶ'),('ｻ');
INSERT INTO `Ｔ４b` VALUES ('ｱ');
INSERT INTO `Ｔ５a` VALUES ('あ'),('か'),('さ');
INSERT INTO `Ｔ５b` VALUES ('あ');
INSERT INTO `Ｔ６a` VALUES ('龔'),('龖'),('龗');
INSERT INTO `Ｔ６b` VALUES ('龔');
INSERT INTO `Ｔ７a` VALUES ('ｱ'),('ｶ'),('ｻ');
INSERT INTO `Ｔ７b` VALUES ('ｱ');
INSERT INTO `Ｔ８a` VALUES ('あ'),('か'),('さ');
INSERT INTO `Ｔ８b` VALUES ('あ');
INSERT INTO `Ｔ９a` VALUES ('龔'),('龖'),('龗');
INSERT INTO `Ｔ９b` VALUES ('龔');

#Test for innodb
SELECT `Ｃ１` FROM `Ｔ１a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ１b`);
SELECT `Ｃ１` FROM `Ｔ１a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ１b` WHERE `Ｔ１a`.`Ｃ１` = `Ｔ１b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ１a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ１b` WHERE `Ｔ１a`.`Ｃ１` = `Ｔ１b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ２a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ２b`);
SELECT `Ｃ１` FROM `Ｔ２a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ２b` WHERE `Ｔ２a`.`Ｃ１` = `Ｔ２b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ２a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ２b` WHERE `Ｔ２a`.`Ｃ１` = `Ｔ２b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ３a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ３b`);
SELECT `Ｃ１` FROM `Ｔ３a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ３b` WHERE `Ｔ３a`.`Ｃ１` = `Ｔ３b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ３a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ３b` WHERE `Ｔ３a`.`Ｃ１` = `Ｔ３b`.`Ｃ１`);
#Test for myisam
SELECT `Ｃ１` FROM `Ｔ４a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ４b`);
SELECT `Ｃ１` FROM `Ｔ４a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ４b` WHERE `Ｔ４a`.`Ｃ１` = `Ｔ４b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ４a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ４b` WHERE `Ｔ４a`.`Ｃ１` = `Ｔ４b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ５a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ５b`);
SELECT `Ｃ１` FROM `Ｔ５a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ５b` WHERE `Ｔ５a`.`Ｃ１` = `Ｔ５b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ５a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ５b` WHERE `Ｔ５a`.`Ｃ１` = `Ｔ５b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ６a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ６b`);
SELECT `Ｃ１` FROM `Ｔ６a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ６b` WHERE `Ｔ６a`.`Ｃ１` = `Ｔ６b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ６a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ６b` WHERE `Ｔ６a`.`Ｃ１` = `Ｔ６b`.`Ｃ１`);
#Test for memory
SELECT `Ｃ１` FROM `Ｔ７a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ７b`);
SELECT `Ｃ１` FROM `Ｔ７a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ７b` WHERE `Ｔ７a`.`Ｃ１` = `Ｔ７b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ７a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ７b` WHERE `Ｔ７a`.`Ｃ１` = `Ｔ７b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ８a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ８b`);
SELECT `Ｃ１` FROM `Ｔ８a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ８b` WHERE `Ｔ８a`.`Ｃ１` = `Ｔ８b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ８a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ８b` WHERE `Ｔ８a`.`Ｃ１` = `Ｔ８b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ９a` WHERE `Ｃ１` IN (SELECT `Ｃ１` FROM `Ｔ９b`);
SELECT `Ｃ１` FROM `Ｔ９a` WHERE EXISTS (SELECT `Ｃ１` FROM `Ｔ９b` WHERE `Ｔ９a`.`Ｃ１` = `Ｔ９b`.`Ｃ１`);
SELECT `Ｃ１` FROM `Ｔ９a` WHERE NOT EXISTS (SELECT `Ｃ１` FROM `Ｔ９b` WHERE `Ｔ９a`.`Ｃ１` = `Ｔ９b`.`Ｃ１`);

DROP TABLE `Ｔ１a`;
DROP TABLE `Ｔ１b`;
DROP TABLE `Ｔ２a`;
DROP TABLE `Ｔ２b`;
DROP TABLE `Ｔ３a`;
DROP TABLE `Ｔ３b`;
DROP TABLE `Ｔ４a`;
DROP TABLE `Ｔ４b`;
DROP TABLE `Ｔ５a`;
DROP TABLE `Ｔ５b`;
DROP TABLE `Ｔ６a`;
DROP TABLE `Ｔ６b`;
DROP TABLE `Ｔ７a`;
DROP TABLE `Ｔ７b`;
DROP TABLE `Ｔ８a`;
DROP TABLE `Ｔ８b`;
DROP TABLE `Ｔ９a`;
DROP TABLE `Ｔ９b`;
