--source include/have_ujis.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 TRIM() function with Japanese characters ujis encoding
#

SET NAMES ujis;
SET character_set_database = ujis;

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

# Nothing to trim
INSERT INTO `Ｔ１` VALUES ('ｱｲｳｴｵ');
# Test data for TRIM(TRAILING [remstr] FROM str)
INSERT INTO `Ｔ１` VALUES ('ｱｲｳｴｵｶ');
INSERT INTO `Ｔ１` VALUES ('ｱｲｳｴｵｶｶ');
INSERT INTO `Ｔ１` VALUES ('ｱｲｳｴｵｶｶｶ');
# Test data for TRIM(LEADING [remstr] FROM str)
INSERT INTO `Ｔ１` VALUES ('ｶｱｲｳｴｵ');
INSERT INTO `Ｔ１` VALUES ('ｶｶｱｲｳｴｵ');
INSERT INTO `Ｔ１` VALUES ('ｶｶｶｱｲｳｴｵ');
# Test data for TRIM(BOTH [remstr] FROM str)
INSERT INTO `Ｔ１` VALUES ('ｶｶｶｱｲｳｴｵｶｶｶ');
# Test data for TRIM without [remstr] (remove spaces) 
INSERT INTO `Ｔ１` VALUES ('   ｱｲｳｴｵ   ');
INSERT INTO `Ｔ２` VALUES ('あいうえお');
INSERT INTO `Ｔ２` VALUES ('あいうえおか');
INSERT INTO `Ｔ２` VALUES ('あいうえおかか');
INSERT INTO `Ｔ２` VALUES ('あいうえおかかか');
INSERT INTO `Ｔ２` VALUES ('かあいうえお');
INSERT INTO `Ｔ２` VALUES ('かかあいうえお');
INSERT INTO `Ｔ２` VALUES ('かかかあいうえお');
INSERT INTO `Ｔ２` VALUES ('かかかあいうえおかかか');
INSERT INTO `Ｔ２` VALUES ('   あいうえお   ');
INSERT INTO `Ｔ３` VALUES ('龔龖龗龞龡');
INSERT INTO `Ｔ３` VALUES ('龔龖龗龞龡丂');
INSERT INTO `Ｔ３` VALUES ('龔龖龗龞龡丂丂');
INSERT INTO `Ｔ３` VALUES ('龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ３` VALUES ('丂龔龖龗龞龡');
INSERT INTO `Ｔ３` VALUES ('丂丂龔龖龗龞龡');
INSERT INTO `Ｔ３` VALUES ('丂丂丂龔龖龗龞龡');
INSERT INTO `Ｔ３` VALUES ('丂丂丂龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ３` VALUES ('   龔龖龗龞龡   ');

INSERT INTO `Ｔ４` VALUES ('ｱｲｳｴｵ');
INSERT INTO `Ｔ４` VALUES ('ｱｲｳｴｵｶ');
INSERT INTO `Ｔ４` VALUES ('ｱｲｳｴｵｶｶ');
INSERT INTO `Ｔ４` VALUES ('ｱｲｳｴｵｶｶｶ');
INSERT INTO `Ｔ４` VALUES ('ｶｱｲｳｴｵ');
INSERT INTO `Ｔ４` VALUES ('ｶｶｱｲｳｴｵ');
INSERT INTO `Ｔ４` VALUES ('ｶｶｶｱｲｳｴｵ');
INSERT INTO `Ｔ４` VALUES ('ｶｶｶｱｲｳｴｵｶｶｶ');
INSERT INTO `Ｔ４` VALUES ('   ｱｲｳｴｵ   ');
INSERT INTO `Ｔ５` VALUES ('あいうえお');
INSERT INTO `Ｔ５` VALUES ('あいうえおか');
INSERT INTO `Ｔ５` VALUES ('あいうえおかか');
INSERT INTO `Ｔ５` VALUES ('あいうえおかかか');
INSERT INTO `Ｔ５` VALUES ('かあいうえお');
INSERT INTO `Ｔ５` VALUES ('かかあいうえお');
INSERT INTO `Ｔ５` VALUES ('かかかあいうえお');
INSERT INTO `Ｔ５` VALUES ('かかかあいうえおかかか');
INSERT INTO `Ｔ５` VALUES ('   あいうえお   ');
INSERT INTO `Ｔ６` VALUES ('龔龖龗龞龡');
INSERT INTO `Ｔ６` VALUES ('龔龖龗龞龡丂');
INSERT INTO `Ｔ６` VALUES ('龔龖龗龞龡丂丂');
INSERT INTO `Ｔ６` VALUES ('龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ６` VALUES ('丂龔龖龗龞龡');
INSERT INTO `Ｔ６` VALUES ('丂丂龔龖龗龞龡');
INSERT INTO `Ｔ６` VALUES ('丂丂丂龔龖龗龞龡');
INSERT INTO `Ｔ６` VALUES ('丂丂丂龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ６` VALUES ('   龔龖龗龞龡   ');

INSERT INTO `Ｔ７` VALUES ('ｱｲｳｴｵ');
INSERT INTO `Ｔ７` VALUES ('ｱｲｳｴｵｶ');
INSERT INTO `Ｔ７` VALUES ('ｱｲｳｴｵｶｶ');
INSERT INTO `Ｔ７` VALUES ('ｱｲｳｴｵｶｶｶ');
INSERT INTO `Ｔ７` VALUES ('ｶｱｲｳｴｵ');
INSERT INTO `Ｔ７` VALUES ('ｶｶｱｲｳｴｵ');
INSERT INTO `Ｔ７` VALUES ('ｶｶｶｱｲｳｴｵ');
INSERT INTO `Ｔ７` VALUES ('ｶｶｶｱｲｳｴｵｶｶｶ');
INSERT INTO `Ｔ７` VALUES ('   ｱｲｳｴｵ   ');
INSERT INTO `Ｔ８` VALUES ('あいうえお');
INSERT INTO `Ｔ８` VALUES ('あいうえおか');
INSERT INTO `Ｔ８` VALUES ('あいうえおかか');
INSERT INTO `Ｔ８` VALUES ('あいうえおかかか');
INSERT INTO `Ｔ８` VALUES ('かあいうえお');
INSERT INTO `Ｔ８` VALUES ('かかあいうえお');
INSERT INTO `Ｔ８` VALUES ('かかかあいうえお');
INSERT INTO `Ｔ８` VALUES ('かかかあいうえおかかか');
INSERT INTO `Ｔ８` VALUES ('   あいうえお   ');
INSERT INTO `Ｔ９` VALUES ('龔龖龗龞龡');
INSERT INTO `Ｔ９` VALUES ('龔龖龗龞龡丂');
INSERT INTO `Ｔ９` VALUES ('龔龖龗龞龡丂丂');
INSERT INTO `Ｔ９` VALUES ('龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ９` VALUES ('丂龔龖龗龞龡');
INSERT INTO `Ｔ９` VALUES ('丂丂龔龖龗龞龡');
INSERT INTO `Ｔ９` VALUES ('丂丂丂龔龖龗龞龡');
INSERT INTO `Ｔ９` VALUES ('丂丂丂龔龖龗龞龡丂丂丂');
INSERT INTO `Ｔ９` VALUES ('   龔龖龗龞龡   ');

#InnoDB
SELECT `Ｃ１`,TRIM(TRAILING 'ｶ' FROM `Ｃ１`) FROM `Ｔ１`;
SELECT `Ｃ１`,TRIM(LEADING 'ｶ' FROM `Ｃ１`) FROM `Ｔ１`;
SELECT `Ｃ１`,TRIM(BOTH 'ｶ' FROM `Ｃ１`) FROM `Ｔ１`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ１`;
SELECT `Ｃ１`,TRIM(TRAILING 'か' FROM `Ｃ１`) FROM `Ｔ２`;
SELECT `Ｃ１`,TRIM(LEADING 'か' FROM `Ｃ１`) FROM `Ｔ２`;
SELECT `Ｃ１`,TRIM(BOTH 'か' FROM `Ｃ１`) FROM `Ｔ２`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ２`;
SELECT `Ｃ１`,TRIM(TRAILING '丂'FROM `Ｃ１`) FROM `Ｔ３`;
SELECT `Ｃ１`,TRIM(LEADING '丂' FROM `Ｃ１`) FROM `Ｔ３`;
SELECT `Ｃ１`,TRIM(BOTH '丂' FROM `Ｃ１`) FROM `Ｔ３`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ３`;

#MyISAM
SELECT `Ｃ１`,TRIM(TRAILING 'ｶ' FROM `Ｃ１`) FROM `Ｔ４`;
SELECT `Ｃ１`,TRIM(LEADING 'ｶ' FROM `Ｃ１`) FROM `Ｔ４`;
SELECT `Ｃ１`,TRIM(BOTH 'ｶ' FROM `Ｃ１`) FROM `Ｔ４`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ４`;
SELECT `Ｃ１`,TRIM(TRAILING 'か' FROM `Ｃ１`) FROM `Ｔ５`;
SELECT `Ｃ１`,TRIM(LEADING 'か' FROM `Ｃ１`) FROM `Ｔ５`;
SELECT `Ｃ１`,TRIM(BOTH 'か' FROM `Ｃ１`) FROM `Ｔ５`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ５`;
SELECT `Ｃ１`,TRIM(TRAILING '丂' FROM `Ｃ１`) FROM `Ｔ６`;
SELECT `Ｃ１`,TRIM(LEADING '丂' FROM `Ｃ１`) FROM `Ｔ６`;
SELECT `Ｃ１`,TRIM(BOTH '丂' FROM `Ｃ１`) FROM `Ｔ６`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ６`;

#MEMORY
SELECT `Ｃ１`,TRIM(TRAILING 'ｶ' FROM `Ｃ１`) FROM `Ｔ７`;
SELECT `Ｃ１`,TRIM(LEADING 'ｶ' FROM `Ｃ１`) FROM `Ｔ７`;
SELECT `Ｃ１`,TRIM(BOTH 'ｶ' FROM `Ｃ１`) FROM `Ｔ７`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ７`;
SELECT `Ｃ１`,TRIM(TRAILING 'か' FROM `Ｃ１`) FROM `Ｔ８`;
SELECT `Ｃ１`,TRIM(LEADING 'か' FROM `Ｃ１`) FROM `Ｔ８`;
SELECT `Ｃ１`,TRIM(BOTH 'か' FROM `Ｃ１`) FROM `Ｔ８`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ８`;
SELECT `Ｃ１`,TRIM(TRAILING '丂' FROM `Ｃ１`) FROM `Ｔ９`;
SELECT `Ｃ１`,TRIM(LEADING '丂' FROM `Ｃ１`) FROM `Ｔ９`;
SELECT `Ｃ１`,TRIM(BOTH '丂' FROM `Ｃ１`) FROM `Ｔ９`;
SELECT `Ｃ１`,TRIM(`Ｃ１`) FROM `Ｔ９`;

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