-- 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 `Ｔ１０`;
--enable_warnings

#
# Test TRIM() function with Japanese characters ucs2 encoding
#

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

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

# 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 ('   龔龖龗龞龡   ');

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

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

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