summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/jp/t
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mysql-test/suite/jp/t/jp_alter_sjis.test318
-rw-r--r--mysql-test/suite/jp/t/jp_alter_ucs2.test320
-rw-r--r--mysql-test/suite/jp/t/jp_alter_ujis.test320
-rw-r--r--mysql-test/suite/jp/t/jp_alter_utf8.test319
-rw-r--r--mysql-test/suite/jp/t/jp_charlength_sjis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_charlength_ucs2.test67
-rw-r--r--mysql-test/suite/jp/t/jp_charlength_ujis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_charlength_utf8.test65
-rw-r--r--mysql-test/suite/jp/t/jp_charset_sjis.test109
-rw-r--r--mysql-test/suite/jp/t/jp_charset_ucs2.test174
-rw-r--r--mysql-test/suite/jp/t/jp_charset_ujis.test110
-rw-r--r--mysql-test/suite/jp/t/jp_charset_utf8.test110
-rw-r--r--mysql-test/suite/jp/t/jp_convert_sjis.test93
-rw-r--r--mysql-test/suite/jp/t/jp_convert_ucs2.test161
-rw-r--r--mysql-test/suite/jp/t/jp_convert_ujis.test95
-rw-r--r--mysql-test/suite/jp/t/jp_convert_utf8.test94
-rw-r--r--mysql-test/suite/jp/t/jp_create_db_sjis.test27
-rw-r--r--mysql-test/suite/jp/t/jp_create_db_ucs2.test29
-rw-r--r--mysql-test/suite/jp/t/jp_create_db_ujis.test28
-rw-r--r--mysql-test/suite/jp/t/jp_create_db_utf8.test27
-rw-r--r--mysql-test/suite/jp/t/jp_create_tbl_sjis.test238
-rw-r--r--mysql-test/suite/jp/t/jp_create_tbl_ucs2.test243
-rw-r--r--mysql-test/suite/jp/t/jp_create_tbl_ujis.test243
-rw-r--r--mysql-test/suite/jp/t/jp_create_tbl_utf8.test242
-rw-r--r--mysql-test/suite/jp/t/jp_enum_sjis.test130
-rw-r--r--mysql-test/suite/jp/t/jp_enum_ucs2.test123
-rw-r--r--mysql-test/suite/jp/t/jp_enum_ujis.test119
-rw-r--r--mysql-test/suite/jp/t/jp_enum_utf8.test118
-rw-r--r--mysql-test/suite/jp/t/jp_insert_sjis.test282
-rw-r--r--mysql-test/suite/jp/t/jp_insert_ucs2.test283
-rw-r--r--mysql-test/suite/jp/t/jp_insert_ujis.test283
-rw-r--r--mysql-test/suite/jp/t/jp_insert_utf8.test281
-rw-r--r--mysql-test/suite/jp/t/jp_instr_sjis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_instr_ucs2.test112
-rw-r--r--mysql-test/suite/jp/t/jp_instr_ujis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_instr_utf8.test110
-rw-r--r--mysql-test/suite/jp/t/jp_join_sjis.test179
-rw-r--r--mysql-test/suite/jp/t/jp_join_ucs2.test180
-rw-r--r--mysql-test/suite/jp/t/jp_join_ujis.test179
-rw-r--r--mysql-test/suite/jp/t/jp_join_utf8.test178
-rw-r--r--mysql-test/suite/jp/t/jp_left_sjis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_left_ucs2.test112
-rw-r--r--mysql-test/suite/jp/t/jp_left_ujis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_left_utf8.test110
-rw-r--r--mysql-test/suite/jp/t/jp_length_sjis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_length_ucs2.test67
-rw-r--r--mysql-test/suite/jp/t/jp_length_ujis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_length_utf8.test65
-rw-r--r--mysql-test/suite/jp/t/jp_like_sjis.test132
-rw-r--r--mysql-test/suite/jp/t/jp_like_ucs2.test209
-rw-r--r--mysql-test/suite/jp/t/jp_like_ujis.test134
-rw-r--r--mysql-test/suite/jp/t/jp_like_utf8.test133
-rw-r--r--mysql-test/suite/jp/t/jp_locate_sjis.test112
-rw-r--r--mysql-test/suite/jp/t/jp_locate_ucs2.test114
-rw-r--r--mysql-test/suite/jp/t/jp_locate_ujis.test113
-rw-r--r--mysql-test/suite/jp/t/jp_locate_utf8.test112
-rw-r--r--mysql-test/suite/jp/t/jp_lpad_sjis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_lpad_ucs2.test67
-rw-r--r--mysql-test/suite/jp/t/jp_lpad_ujis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_lpad_utf8.test65
-rw-r--r--mysql-test/suite/jp/t/jp_ltrim_sjis.test129
-rw-r--r--mysql-test/suite/jp/t/jp_ltrim_ucs2.test130
-rw-r--r--mysql-test/suite/jp/t/jp_ltrim_ujis.test129
-rw-r--r--mysql-test/suite/jp/t/jp_ltrim_utf8.test128
-rw-r--r--mysql-test/suite/jp/t/jp_ps_sjis.test348
-rw-r--r--mysql-test/suite/jp/t/jp_ps_ujis.test347
-rw-r--r--mysql-test/suite/jp/t/jp_replace_sjis.test102
-rw-r--r--mysql-test/suite/jp/t/jp_replace_ucs2.test103
-rw-r--r--mysql-test/suite/jp/t/jp_replace_ujis.test102
-rw-r--r--mysql-test/suite/jp/t/jp_replace_utf8.test101
-rw-r--r--mysql-test/suite/jp/t/jp_reverse_sjis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_reverse_ucs2.test67
-rw-r--r--mysql-test/suite/jp/t/jp_reverse_ujis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_reverse_utf8.test65
-rw-r--r--mysql-test/suite/jp/t/jp_right_sjis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_right_ucs2.test112
-rw-r--r--mysql-test/suite/jp/t/jp_right_ujis.test111
-rw-r--r--mysql-test/suite/jp/t/jp_right_utf8.test110
-rw-r--r--mysql-test/suite/jp/t/jp_rpad_sjis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_rpad_ucs2.test67
-rw-r--r--mysql-test/suite/jp/t/jp_rpad_ujis.test66
-rw-r--r--mysql-test/suite/jp/t/jp_rpad_utf8.test66
-rw-r--r--mysql-test/suite/jp/t/jp_rtrim_sjis.test129
-rw-r--r--mysql-test/suite/jp/t/jp_rtrim_ucs2.test130
-rw-r--r--mysql-test/suite/jp/t/jp_rtrim_ujis.test129
-rw-r--r--mysql-test/suite/jp/t/jp_rtrim_utf8.test128
-rw-r--r--mysql-test/suite/jp/t/jp_select_sjis.test69
-rw-r--r--mysql-test/suite/jp/t/jp_select_ucs2.test135
-rw-r--r--mysql-test/suite/jp/t/jp_select_ujis.test69
-rw-r--r--mysql-test/suite/jp/t/jp_select_utf8.test68
-rw-r--r--mysql-test/suite/jp/t/jp_subquery_sjis.test112
-rw-r--r--mysql-test/suite/jp/t/jp_subquery_ucs2.test122
-rw-r--r--mysql-test/suite/jp/t/jp_subquery_ujis.test121
-rw-r--r--mysql-test/suite/jp/t/jp_subquery_utf8.test114
-rw-r--r--mysql-test/suite/jp/t/jp_substring_sjis.test316
-rw-r--r--mysql-test/suite/jp/t/jp_substring_ucs2.test319
-rw-r--r--mysql-test/suite/jp/t/jp_substring_ujis.test315
-rw-r--r--mysql-test/suite/jp/t/jp_substring_utf8.test314
-rw-r--r--mysql-test/suite/jp/t/jp_trim_sjis.test13
-rw-r--r--mysql-test/suite/jp/t/jp_trim_ucs2.test173
-rw-r--r--mysql-test/suite/jp/t/jp_trim_ujis.test172
-rw-r--r--mysql-test/suite/jp/t/jp_trim_utf8.test171
-rw-r--r--mysql-test/suite/jp/t/jp_union_ujis.test103
-rw-r--r--mysql-test/suite/jp/t/jp_update_sjis.test76
-rw-r--r--mysql-test/suite/jp/t/jp_update_ucs2.test77
-rw-r--r--mysql-test/suite/jp/t/jp_update_ujis.test76
-rw-r--r--mysql-test/suite/jp/t/jp_update_utf8.test75
-rw-r--r--mysql-test/suite/jp/t/jp_where_sjis.test93
-rw-r--r--mysql-test/suite/jp/t/jp_where_ucs2.test137
-rw-r--r--mysql-test/suite/jp/t/jp_where_ujis.test71
-rw-r--r--mysql-test/suite/jp/t/jp_where_utf8.test70
111 files changed, 14863 insertions, 0 deletions
diff --git a/mysql-test/suite/jp/t/jp_alter_sjis.test b/mysql-test/suite/jp/t/jp_alter_sjis.test
new file mode 100644
index 00000000..ec3abf01
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_alter_sjis.test
@@ -0,0 +1,318 @@
+--source include/have_sjis.inc
+--character_set sjis
+SET NAMES sjis;
+SET character_set_database = sjis;
+--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 `十十十`;
+--enable_warnings
+
+#
+# Test altering table with Japanese characters in sjis encoding
+#
+
+#
+# Test InnoDB
+#
+CREATE TABLE `アアア`(`キキキ` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `イイイ`(`ケケケ` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `あああ`(`ききき` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `いいい`(`けけけ` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `ソソソ`(`表表表` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `十十十`(`予予予` char(5)) DEFAULT CHARSET = sjis engine=INNODB;
+
+INSERT INTO `アアア` VALUES ('アアアアア'),('イイイイイ'),('ウウウウウ');
+INSERT INTO `あああ` VALUES ('あああああ'),('いいいいい'),('ううううう');
+INSERT INTO `ソソソ` VALUES ('表表表表表'),('構構構構構'),('能能能能能');
+
+# Test basic alter operation
+
+ALTER TABLE `アアア` ADD `カカカ` char(1) FIRST;
+ALTER TABLE `アアア` ADD `ククク` char(1) AFTER `キキキ`;
+ALTER TABLE `アアア` ADD `ケケケ` char(1);
+ALTER TABLE `アアア` ADD INDEX (`カカカ`);
+ALTER TABLE `アアア` ADD PRIMARY KEY (`キキキ`);
+ALTER TABLE `アアア` ADD UNIQUE (`ククク`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `アアア` ADD FOREIGN KEY (`ケケケ`) REFERENCES `イイイ`(`ケケケ`);
+ALTER TABLE `アアア` CHANGE `カカカ` `カカ` char(1);
+ALTER TABLE `アアア` MODIFY `キキキ` char(6);
+
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `アアア` DROP INDEX `カカカ`;
+ALTER TABLE `アアア` DROP PRIMARY KEY;
+ALTER TABLE `アアア` DROP INDEX `ククク`;
+#ALTER TABLE `アアア` DROP FOREIGN KEY `ケケケ`;
+ALTER TABLE `アアア` DROP `カカ`;
+ALTER TABLE `アアア` DROP `ククク`;
+ALTER TABLE `アアア` DROP `ケケケ`;
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `あああ` ADD `かかか` char(1) FIRST;
+ALTER TABLE `あああ` ADD `くくく` char(1) AFTER `ききき`;
+ALTER TABLE `あああ` ADD `けけけ` char(1);
+ALTER TABLE `あああ` ADD INDEX (`かかか`);
+ALTER TABLE `あああ` ADD PRIMARY KEY (`ききき`);
+ALTER TABLE `あああ` ADD UNIQUE (`くくく`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `あああ` ADD FOREIGN KEY (`けけけ`) REFERENCES `いいい`(`けけけ`);
+ALTER TABLE `あああ` CHANGE `かかか` `かか` char(1);
+ALTER TABLE `あああ` MODIFY `ききき` char(6);
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `あああ` DROP INDEX `かかか`;
+ALTER TABLE `あああ` DROP PRIMARY KEY;
+ALTER TABLE `あああ` DROP INDEX `くくく`;
+#ALTER TABLE `あああ` DROP FOREIGN KEY `けけけ`;
+ALTER TABLE `あああ` DROP `かか`;
+ALTER TABLE `あああ` DROP `くくく`;
+ALTER TABLE `あああ` DROP `けけけ`;
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `ソソソ` ADD `構構構` char(1) FIRST;
+ALTER TABLE `ソソソ` ADD `能能能` char(1) AFTER `表表表`;
+ALTER TABLE `ソソソ` ADD `予予予` char(1);
+ALTER TABLE `ソソソ` ADD INDEX (`構構構`);
+ALTER TABLE `ソソソ` ADD PRIMARY KEY (`表表表`);
+ALTER TABLE `ソソソ` ADD UNIQUE (`能能能`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `ソソソ` ADD FOREIGN KEY (`予予予`) REFERENCES `十十十`(`予予予`);
+ALTER TABLE `ソソソ` CHANGE `構構構` `構構` char(1);
+ALTER TABLE `ソソソ` MODIFY `表表表` char(6);
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+ALTER TABLE `ソソソ` DROP INDEX `構構構`;
+ALTER TABLE `ソソソ` DROP PRIMARY KEY;
+ALTER TABLE `ソソソ` DROP INDEX `能能能`;
+#ALTER TABLE `ソソソ` DROP FOREIGN KEY `予予予`;
+ALTER TABLE `ソソソ` DROP `構構`;
+ALTER TABLE `ソソソ` DROP `能能能`;
+ALTER TABLE `ソソソ` DROP `予予予`;
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
+
+#
+# Test MyISAM
+#
+
+CREATE TABLE `アアア`(`キキキ` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+CREATE TABLE `イイイ`(`ケケケ` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+CREATE TABLE `あああ`(`ききき` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+CREATE TABLE `いいい`(`けけけ` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+CREATE TABLE `ソソソ`(`表表表` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+CREATE TABLE `十十十`(`予予予` char(5)) DEFAULT CHARSET = sjis engine=MYISAM;
+
+INSERT INTO `アアア` VALUES ('アアアアア'),('イイイイイ'),('ウウウウウ');
+INSERT INTO `あああ` VALUES ('あああああ'),('いいいいい'),('ううううう');
+INSERT INTO `ソソソ` VALUES ('表表表表表'),('構構構構構'),('能能能能能');
+
+ALTER TABLE `アアア` ADD `カカカ` char(1) FIRST;
+ALTER TABLE `アアア` ADD `ククク` char(1) AFTER `キキキ`;
+ALTER TABLE `アアア` ADD `ケケケ` char(1);
+ALTER TABLE `アアア` ADD INDEX (`カカカ`);
+ALTER TABLE `アアア` ADD PRIMARY KEY (`キキキ`);
+ALTER TABLE `アアア` ADD UNIQUE (`ククク`);
+#ALTER TABLE `アアア` ADD FOREIGN KEY (`ケケケ`) REFERENCES `イイイ`(`ケケケ`);
+ALTER TABLE `アアア` CHANGE `カカカ` `カカ` char(1);
+ALTER TABLE `アアア` MODIFY `キキキ` char(6);
+
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `アアア` DROP INDEX `カカカ`;
+ALTER TABLE `アアア` DROP PRIMARY KEY;
+ALTER TABLE `アアア` DROP INDEX `ククク`;
+#ALTER TABLE `アアア` DROP FOREIGN KEY `ケケケ`;
+ALTER TABLE `アアア` DROP `カカ`;
+ALTER TABLE `アアア` DROP `ククク`;
+ALTER TABLE `アアア` DROP `ケケケ`;
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `あああ` ADD `かかか` char(1) FIRST;
+ALTER TABLE `あああ` ADD `くくく` char(1) AFTER `ききき`;
+ALTER TABLE `あああ` ADD `けけけ` char(1);
+ALTER TABLE `あああ` ADD INDEX (`かかか`);
+ALTER TABLE `あああ` ADD PRIMARY KEY (`ききき`);
+ALTER TABLE `あああ` ADD UNIQUE (`くくく`);
+#ALTER TABLE `あああ` ADD FOREIGN KEY (`けけけ`) REFERENCES `いいい`(`けけけ`);
+ALTER TABLE `あああ` CHANGE `かかか` `かか` char(1);
+ALTER TABLE `あああ` MODIFY `ききき` char(6);
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `あああ` DROP INDEX `かかか`;
+ALTER TABLE `あああ` DROP PRIMARY KEY;
+ALTER TABLE `あああ` DROP INDEX `くくく`;
+#ALTER TABLE `あああ` DROP FOREIGN KEY `けけけ`;
+ALTER TABLE `あああ` DROP `かか`;
+ALTER TABLE `あああ` DROP `くくく`;
+ALTER TABLE `あああ` DROP `けけけ`;
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `ソソソ` ADD `構構構` char(1) FIRST;
+ALTER TABLE `ソソソ` ADD `能能能` char(1) AFTER `表表表`;
+ALTER TABLE `ソソソ` ADD `予予予` char(1);
+ALTER TABLE `ソソソ` ADD INDEX (`構構構`);
+ALTER TABLE `ソソソ` ADD PRIMARY KEY (`表表表`);
+ALTER TABLE `ソソソ` ADD UNIQUE (`能能能`);
+#ALTER TABLE `ソソソ` ADD FOREIGN KEY (`予予予`) REFERENCES `十十十`(`予予予`);
+ALTER TABLE `ソソソ` CHANGE `構構構` `構構` char(1);
+ALTER TABLE `ソソソ` MODIFY `表表表` char(6);
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+ALTER TABLE `ソソソ` DROP INDEX `構構構`;
+ALTER TABLE `ソソソ` DROP PRIMARY KEY;
+ALTER TABLE `ソソソ` DROP INDEX `能能能`;
+#ALTER TABLE `ソソソ` DROP FOREIGN KEY `予予予`;
+ALTER TABLE `ソソソ` DROP `構構`;
+ALTER TABLE `ソソソ` DROP `能能能`;
+ALTER TABLE `ソソソ` DROP `予予予`;
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
+
+#
+# Test MEMORY
+#
+
+CREATE TABLE `アアア`(`キキキ` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `イイイ`(`ケケケ` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `あああ`(`ききき` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `いいい`(`けけけ` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `ソソソ`(`表表表` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `十十十`(`予予予` char(5)) DEFAULT CHARSET = sjis engine=MEMORY;
+
+INSERT INTO `アアア` VALUES ('アアアアア'),('イイイイイ'),('ウウウウウ');
+INSERT INTO `あああ` VALUES ('あああああ'),('いいいいい'),('ううううう');
+INSERT INTO `ソソソ` VALUES ('表表表表表'),('構構構構構'),('能能能能能');
+
+ALTER TABLE `アアア` ADD `カカカ` char(1) FIRST;
+ALTER TABLE `アアア` ADD `ククク` char(1) AFTER `キキキ`;
+ALTER TABLE `アアア` ADD `ケケケ` char(1);
+ALTER TABLE `アアア` ADD INDEX (`カカカ`);
+ALTER TABLE `アアア` ADD PRIMARY KEY (`キキキ`);
+ALTER TABLE `アアア` ADD UNIQUE (`ククク`);
+#ALTER TABLE `アアア` ADD FOREIGN KEY (`ケケケ`) REFERENCES `イイイ`(`ケケケ`);
+ALTER TABLE `アアア` CHANGE `カカカ` `カカ` char(1);
+ALTER TABLE `アアア` MODIFY `キキキ` char(6);
+
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `アアア` DROP INDEX `カカカ`;
+ALTER TABLE `アアア` DROP PRIMARY KEY;
+ALTER TABLE `アアア` DROP INDEX `ククク`;
+#ALTER TABLE `アアア` DROP FOREIGN KEY `ケケケ`;
+ALTER TABLE `アアア` DROP `カカ`;
+ALTER TABLE `アアア` DROP `ククク`;
+ALTER TABLE `アアア` DROP `ケケケ`;
+SELECT * FROM `アアア`;
+DESC `アアア`;
+SHOW CREATE TABLE `アアア`;
+
+ALTER TABLE `あああ` ADD `かかか` char(1) FIRST;
+ALTER TABLE `あああ` ADD `くくく` char(1) AFTER `ききき`;
+ALTER TABLE `あああ` ADD `けけけ` char(1);
+ALTER TABLE `あああ` ADD INDEX (`かかか`);
+ALTER TABLE `あああ` ADD PRIMARY KEY (`ききき`);
+ALTER TABLE `あああ` ADD UNIQUE (`くくく`);
+#ALTER TABLE `あああ` ADD FOREIGN KEY (`けけけ`) REFERENCES `いいい`(`けけけ`);
+ALTER TABLE `あああ` CHANGE `かかか` `かか` char(1);
+ALTER TABLE `あああ` MODIFY `ききき` char(6);
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `あああ` DROP INDEX `かかか`;
+ALTER TABLE `あああ` DROP PRIMARY KEY;
+ALTER TABLE `あああ` DROP INDEX `くくく`;
+#ALTER TABLE `あああ` DROP FOREIGN KEY `けけけ`;
+ALTER TABLE `あああ` DROP `かか`;
+ALTER TABLE `あああ` DROP `くくく`;
+ALTER TABLE `あああ` DROP `けけけ`;
+
+SELECT * FROM `あああ`;
+DESC `あああ`;
+SHOW CREATE TABLE `あああ`;
+
+ALTER TABLE `ソソソ` ADD `構構構` char(1) FIRST;
+ALTER TABLE `ソソソ` ADD `能能能` char(1) AFTER `表表表`;
+ALTER TABLE `ソソソ` ADD `予予予` char(1);
+ALTER TABLE `ソソソ` ADD INDEX (`構構構`);
+ALTER TABLE `ソソソ` ADD PRIMARY KEY (`表表表`);
+ALTER TABLE `ソソソ` ADD UNIQUE (`能能能`);
+#ALTER TABLE `ソソソ` ADD FOREIGN KEY (`予予予`) REFERENCES `十十十`(`予予予`);
+ALTER TABLE `ソソソ` CHANGE `構構構` `構構` char(1);
+ALTER TABLE `ソソソ` MODIFY `表表表` char(6);
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+ALTER TABLE `ソソソ` DROP INDEX `構構構`;
+ALTER TABLE `ソソソ` DROP PRIMARY KEY;
+ALTER TABLE `ソソソ` DROP INDEX `能能能`;
+#ALTER TABLE `ソソソ` DROP FOREIGN KEY `予予予`;
+ALTER TABLE `ソソソ` DROP `構構`;
+ALTER TABLE `ソソソ` DROP `能能能`;
+ALTER TABLE `ソソソ` DROP `予予予`;
+
+SELECT * FROM `ソソソ`;
+DESC `ソソソ`;
+SHOW CREATE TABLE `ソソソ`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
diff --git a/mysql-test/suite/jp/t/jp_alter_ucs2.test b/mysql-test/suite/jp/t/jp_alter_ucs2.test
new file mode 100644
index 00000000..24cfed06
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_alter_ucs2.test
@@ -0,0 +1,320 @@
+--source include/have_ucs2.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 `常゙常゙常゙`;
+--enable_warnings
+
+#
+# Test altering table with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+#
+# Test InnoDB
+#
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ucs2 engine=INNODB;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+# Test basic alter operation
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+
+#
+# Test MyISAM
+#
+
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ucs2 engine=MYISAM;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+
+#
+# Test MEMORY
+#
+
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
diff --git a/mysql-test/suite/jp/t/jp_alter_ujis.test b/mysql-test/suite/jp/t/jp_alter_ujis.test
new file mode 100644
index 00000000..e397cf66
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_alter_ujis.test
@@ -0,0 +1,320 @@
+--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 `常゙常゙常゙`;
+--enable_warnings
+
+#
+# Test altering table with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+#
+# Test InnoDB
+#
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ujis engine=INNODB;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+# Test basic alter operation
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+
+#
+# Test MyISAM
+#
+
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ujis engine=MYISAM;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+
+#
+# Test MEMORY
+#
+
+CREATE TABLE `竺竺竺`(`執執執` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `軸軸軸`(`嫉嫉嫉` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `、「、「、「`(`、ュ、ュ、ュ` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `、、、、、、`(`、ア、ア、ア` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `常゙常゙常゙`(`床エ床エ床エ` char(5)) DEFAULT CHARSET = ujis engine=MEMORY;
+
+INSERT INTO `竺竺竺` VALUES ('竺竺竺竺竺'),('軸軸軸軸軸'),('宍宍宍宍宍');
+INSERT INTO `、「、「、「` VALUES ('、「、「、「、「、「'),('、、、、、、、、、、'),('、ヲ、ヲ、ヲ、ヲ、ヲ');
+INSERT INTO `常ン常ン常ン` VALUES ('床。床。床。床。床。'),('床「床「床「床「床「'),('床」床」床」床」床」');
+
+ALTER TABLE `竺竺竺` ADD `叱叱叱` char(1) FIRST;
+ALTER TABLE `竺竺竺` ADD `失失失` char(1) AFTER `執執執`;
+ALTER TABLE `竺竺竺` ADD `嫉嫉嫉` char(1);
+ALTER TABLE `竺竺竺` ADD INDEX (`叱叱叱`);
+ALTER TABLE `竺竺竺` ADD PRIMARY KEY (`執執執`);
+ALTER TABLE `竺竺竺` ADD UNIQUE (`失失失`);
+#ALTER TABLE `竺竺竺` ADD FOREIGN KEY (`嫉嫉嫉`) REFERENCES `軸軸軸`(`嫉嫉嫉`);
+ALTER TABLE `竺竺竺` CHANGE `叱叱叱` `叱叱` char(1);
+ALTER TABLE `竺竺竺` MODIFY `執執執` char(6);
+
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `竺竺竺` DROP INDEX `叱叱叱`;
+ALTER TABLE `竺竺竺` DROP PRIMARY KEY;
+ALTER TABLE `竺竺竺` DROP INDEX `失失失`;
+#ALTER TABLE `竺竺竺` DROP FOREIGN KEY `嫉嫉嫉`;
+ALTER TABLE `竺竺竺` DROP `叱叱`;
+ALTER TABLE `竺竺竺` DROP `失失失`;
+ALTER TABLE `竺竺竺` DROP `嫉嫉嫉`;
+SELECT * FROM `竺竺竺`;
+DESC `竺竺竺`;
+SHOW CREATE TABLE `竺竺竺`;
+
+ALTER TABLE `、「、「、「` ADD `、ォ、ォ、ォ` char(1) FIRST;
+ALTER TABLE `、「、「、「` ADD `、ッ、ッ、ッ` char(1) AFTER `、ュ、ュ、ュ`;
+ALTER TABLE `、「、「、「` ADD `、ア、ア、ア` char(1);
+ALTER TABLE `、「、「、「` ADD INDEX (`、ォ、ォ、ォ`);
+ALTER TABLE `、「、「、「` ADD PRIMARY KEY (`、ュ、ュ、ュ`);
+ALTER TABLE `、「、「、「` ADD UNIQUE (`、ッ、ッ、ッ`);
+#ALTER TABLE `、「、「、「` ADD FOREIGN KEY (`、ア、ア、ア`) REFERENCES `、、、、、、`(`、ア、ア、ア`);
+ALTER TABLE `、「、「、「` CHANGE `、ォ、ォ、ォ` `、ォ、ォ` char(1);
+ALTER TABLE `、「、「、「` MODIFY `、ュ、ュ、ュ` char(6);
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `、「、「、「` DROP INDEX `、ォ、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP PRIMARY KEY;
+ALTER TABLE `、「、「、「` DROP INDEX `、ッ、ッ、ッ`;
+#ALTER TABLE `、「、「、「` DROP FOREIGN KEY `、ア、ア、ア`;
+ALTER TABLE `、「、「、「` DROP `、ォ、ォ`;
+ALTER TABLE `、「、「、「` DROP `、ッ、ッ、ッ`;
+ALTER TABLE `、「、「、「` DROP `、ア、ア、ア`;
+
+SELECT * FROM `、「、「、「`;
+DESC `、「、「、「`;
+SHOW CREATE TABLE `、「、「、「`;
+
+ALTER TABLE `常ン常ン常ン` ADD `床「床「床「` char(1) FIRST;
+ALTER TABLE `常ン常ン常ン` ADD `床」床」床」` char(1) AFTER `床。床。床。`;
+ALTER TABLE `常ン常ン常ン` ADD `床エ床エ床エ` char(1);
+ALTER TABLE `常ン常ン常ン` ADD INDEX (`床「床「床「`);
+ALTER TABLE `常ン常ン常ン` ADD PRIMARY KEY (`床。床。床。`);
+ALTER TABLE `常ン常ン常ン` ADD UNIQUE (`床」床」床」`);
+#ALTER TABLE `常ン常ン常ン` ADD FOREIGN KEY (`床エ床エ床エ`) REFERENCES `常゙常゙常゙`(`床エ床エ床エ`);
+ALTER TABLE `常ン常ン常ン` CHANGE `床「床「床「` `床「床「` char(1);
+ALTER TABLE `常ン常ン常ン` MODIFY `床。床。床。` char(6);
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床「床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP PRIMARY KEY;
+ALTER TABLE `常ン常ン常ン` DROP INDEX `床」床」床」`;
+#ALTER TABLE `常ン常ン常ン` DROP FOREIGN KEY `床エ床エ床エ`;
+ALTER TABLE `常ン常ン常ン` DROP `床「床「`;
+ALTER TABLE `常ン常ン常ン` DROP `床」床」床」`;
+ALTER TABLE `常ン常ン常ン` DROP `床エ床エ床エ`;
+
+SELECT * FROM `常ン常ン常ン`;
+DESC `常ン常ン常ン`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
diff --git a/mysql-test/suite/jp/t/jp_alter_utf8.test b/mysql-test/suite/jp/t/jp_alter_utf8.test
new file mode 100644
index 00000000..fc98e20a
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_alter_utf8.test
@@ -0,0 +1,319 @@
+--disable_warnings
+DROP TABLE IF EXISTS `スアスアスア`;
+DROP TABLE IF EXISTS `スイスイスイ`;
+DROP TABLE IF EXISTS `縺ゅ≠縺A;
+DROP TABLE IF EXISTS `縺縺縺Я;
+DROP TABLE IF EXISTS `鮴夜セ夜セ冒;
+DROP TABLE IF EXISTS `鮴鈴セ鈴セ輿;
+--enable_warnings
+
+#
+# Test altering table with Japanese characters in utf8 encoding
+#
+
+--source include/have_utf8.inc
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+--source include/have_innodb.inc
+
+#
+# Test InnoDB
+#
+CREATE TABLE `スアスアスア`(`スキスキスキ` char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `スイスイスイ`(`スケスケスケ` char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `縺ゅ≠縺A(`縺阪″縺港 char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `縺縺縺Я(`縺代¢縺疏 char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻 char(5)) DEFAULT CHARSET = utf8 engine=INNODB;
+
+INSERT INTO `スアスアスア` VALUES ('スアスアスアスアスア'),('スイスイスイスイスイ'),('スウスウスウスウスウ');
+INSERT INTO `縺ゅ≠縺A VALUES ('縺ゅ≠縺ゅ≠縺'),('縺縺縺縺縺'),('縺縺縺縺縺');
+INSERT INTO `鮴夜セ夜セ冒 VALUES ('荳ゆクゆクゆクゆク'),('荳荳荳荳荳'),('荳荳荳荳荳');
+
+# Test basic alter operation
+
+ALTER TABLE `スアスアスア` ADD `スカスカスカ` char(1) FIRST;
+ALTER TABLE `スアスアスア` ADD `スクスクスク` char(1) AFTER `スキスキスキ`;
+ALTER TABLE `スアスアスア` ADD `スケスケスケ` char(1);
+ALTER TABLE `スアスアスア` ADD INDEX (`スカスカスカ`);
+ALTER TABLE `スアスアスア` ADD PRIMARY KEY (`スキスキスキ`);
+ALTER TABLE `スアスアスア` ADD UNIQUE (`スクスクスク`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `スアスアスア` ADD FOREIGN KEY (`スケスケスケ`) REFERENCES `スイスイスイ`(`スケスケスケ`);
+ALTER TABLE `スアスアスア` CHANGE `スカスカスカ` `スカスカ` char(1);
+ALTER TABLE `スアスアスア` MODIFY `スキスキスキ` char(6);
+
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `スアスアスア` DROP INDEX `スカスカスカ`;
+ALTER TABLE `スアスアスア` DROP PRIMARY KEY;
+ALTER TABLE `スアスアスア` DROP INDEX `スクスクスク`;
+#ALTER TABLE `スアスアスア` DROP FOREIGN KEY `スケスケスケ`;
+ALTER TABLE `スアスアスア` DROP `スカスカ`;
+ALTER TABLE `スアスアスア` DROP `スクスクスク`;
+ALTER TABLE `スアスアスア` DROP `スケスケスケ`;
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `縺ゅ≠縺A ADD `縺九°縺義 char(1) FIRST;
+ALTER TABLE `縺ゅ≠縺A ADD `縺上¥縺汁 char(1) AFTER `縺阪″縺港;
+ALTER TABLE `縺ゅ≠縺A ADD `縺代¢縺疏 char(1);
+ALTER TABLE `縺ゅ≠縺A ADD INDEX (`縺九°縺義);
+ALTER TABLE `縺ゅ≠縺A ADD PRIMARY KEY (`縺阪″縺港);
+ALTER TABLE `縺ゅ≠縺A ADD UNIQUE (`縺上¥縺汁);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `縺ゅ≠縺A ADD FOREIGN KEY (`縺代¢縺疏) REFERENCES `縺縺縺Я(`縺代¢縺疏);
+ALTER TABLE `縺ゅ≠縺A CHANGE `縺九°縺義 `縺九°` char(1);
+ALTER TABLE `縺ゅ≠縺A MODIFY `縺阪″縺港 char(6);
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺九°縺義;
+ALTER TABLE `縺ゅ≠縺A DROP PRIMARY KEY;
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺上¥縺汁;
+#ALTER TABLE `縺ゅ≠縺A DROP FOREIGN KEY `縺代¢縺疏;
+ALTER TABLE `縺ゅ≠縺A DROP `縺九°`;
+ALTER TABLE `縺ゅ≠縺A DROP `縺上¥縺汁;
+ALTER TABLE `縺ゅ≠縺A DROP `縺代¢縺疏;
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳Я char(1) FIRST;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳` char(1) AFTER `荳ゆクゆクA;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荵壻ケ壻ケ啻 char(1);
+ALTER TABLE `鮴夜セ夜セ冒 ADD INDEX (`荳荳荳Я);
+ALTER TABLE `鮴夜セ夜セ冒 ADD PRIMARY KEY (`荳ゆクゆクA);
+ALTER TABLE `鮴夜セ夜セ冒 ADD UNIQUE (`荳荳荳`);
+#Multi-byte field name is not allowed for FOREIGN KEY As of 4.1.4
+#ALTER TABLE `鮴夜セ夜セ冒 ADD FOREIGN KEY (`荵壻ケ壻ケ啻) REFERENCES `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻);
+ALTER TABLE `鮴夜セ夜セ冒 CHANGE `荳荳荳Я `荳荳Я char(1);
+ALTER TABLE `鮴夜セ夜セ冒 MODIFY `荳ゆクゆクA char(6);
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP PRIMARY KEY;
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳`;
+#ALTER TABLE `鮴夜セ夜セ冒 DROP FOREIGN KEY `荵壻ケ壻ケ啻;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳荳`;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荵壻ケ壻ケ啻;
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
+
+#
+# Test MyISAM
+#
+
+CREATE TABLE `スアスアスア`(`スキスキスキ` char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+CREATE TABLE `スイスイスイ`(`スケスケスケ` char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+CREATE TABLE `縺ゅ≠縺A(`縺阪″縺港 char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+CREATE TABLE `縺縺縺Я(`縺代¢縺疏 char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻 char(5)) DEFAULT CHARSET = utf8 engine=MYISAM;
+
+INSERT INTO `スアスアスア` VALUES ('スアスアスアスアスア'),('スイスイスイスイスイ'),('スウスウスウスウスウ');
+INSERT INTO `縺ゅ≠縺A VALUES ('縺ゅ≠縺ゅ≠縺'),('縺縺縺縺縺'),('縺縺縺縺縺');
+INSERT INTO `鮴夜セ夜セ冒 VALUES ('荳ゆクゆクゆクゆク'),('荳荳荳荳荳'),('荳荳荳荳荳');
+
+ALTER TABLE `スアスアスア` ADD `スカスカスカ` char(1) FIRST;
+ALTER TABLE `スアスアスア` ADD `スクスクスク` char(1) AFTER `スキスキスキ`;
+ALTER TABLE `スアスアスア` ADD `スケスケスケ` char(1);
+ALTER TABLE `スアスアスア` ADD INDEX (`スカスカスカ`);
+ALTER TABLE `スアスアスア` ADD PRIMARY KEY (`スキスキスキ`);
+ALTER TABLE `スアスアスア` ADD UNIQUE (`スクスクスク`);
+#ALTER TABLE `スアスアスア` ADD FOREIGN KEY (`スケスケスケ`) REFERENCES `スイスイスイ`(`スケスケスケ`);
+ALTER TABLE `スアスアスア` CHANGE `スカスカスカ` `スカスカ` char(1);
+ALTER TABLE `スアスアスア` MODIFY `スキスキスキ` char(6);
+
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `スアスアスア` DROP INDEX `スカスカスカ`;
+ALTER TABLE `スアスアスア` DROP PRIMARY KEY;
+ALTER TABLE `スアスアスア` DROP INDEX `スクスクスク`;
+#ALTER TABLE `スアスアスア` DROP FOREIGN KEY `スケスケスケ`;
+ALTER TABLE `スアスアスア` DROP `スカスカ`;
+ALTER TABLE `スアスアスア` DROP `スクスクスク`;
+ALTER TABLE `スアスアスア` DROP `スケスケスケ`;
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `縺ゅ≠縺A ADD `縺九°縺義 char(1) FIRST;
+ALTER TABLE `縺ゅ≠縺A ADD `縺上¥縺汁 char(1) AFTER `縺阪″縺港;
+ALTER TABLE `縺ゅ≠縺A ADD `縺代¢縺疏 char(1);
+ALTER TABLE `縺ゅ≠縺A ADD INDEX (`縺九°縺義);
+ALTER TABLE `縺ゅ≠縺A ADD PRIMARY KEY (`縺阪″縺港);
+ALTER TABLE `縺ゅ≠縺A ADD UNIQUE (`縺上¥縺汁);
+#ALTER TABLE `縺ゅ≠縺A ADD FOREIGN KEY (`縺代¢縺疏) REFERENCES `縺縺縺Я(`縺代¢縺疏);
+ALTER TABLE `縺ゅ≠縺A CHANGE `縺九°縺義 `縺九°` char(1);
+ALTER TABLE `縺ゅ≠縺A MODIFY `縺阪″縺港 char(6);
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺九°縺義;
+ALTER TABLE `縺ゅ≠縺A DROP PRIMARY KEY;
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺上¥縺汁;
+#ALTER TABLE `縺ゅ≠縺A DROP FOREIGN KEY `縺代¢縺疏;
+ALTER TABLE `縺ゅ≠縺A DROP `縺九°`;
+ALTER TABLE `縺ゅ≠縺A DROP `縺上¥縺汁;
+ALTER TABLE `縺ゅ≠縺A DROP `縺代¢縺疏;
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳Я char(1) FIRST;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳` char(1) AFTER `荳ゆクゆクA;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荵壻ケ壻ケ啻 char(1);
+ALTER TABLE `鮴夜セ夜セ冒 ADD INDEX (`荳荳荳Я);
+ALTER TABLE `鮴夜セ夜セ冒 ADD PRIMARY KEY (`荳ゆクゆクA);
+ALTER TABLE `鮴夜セ夜セ冒 ADD UNIQUE (`荳荳荳`);
+#ALTER TABLE `鮴夜セ夜セ冒 ADD FOREIGN KEY (`荵壻ケ壻ケ啻) REFERENCES `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻);
+ALTER TABLE `鮴夜セ夜セ冒 CHANGE `荳荳荳Я `荳荳Я char(1);
+ALTER TABLE `鮴夜セ夜セ冒 MODIFY `荳ゆクゆクA char(6);
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP PRIMARY KEY;
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳`;
+#ALTER TABLE `鮴夜セ夜セ冒 DROP FOREIGN KEY `荵壻ケ壻ケ啻;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳荳`;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荵壻ケ壻ケ啻;
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
+
+#
+# Test MEMORY
+#
+
+CREATE TABLE `スアスアスア`(`スキスキスキ` char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `スイスイスイ`(`スケスケスケ` char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `縺ゅ≠縺A(`縺阪″縺港 char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `縺縺縺Я(`縺代¢縺疏 char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻 char(5)) DEFAULT CHARSET = utf8 engine=MEMORY;
+
+INSERT INTO `スアスアスア` VALUES ('スアスアスアスアスア'),('スイスイスイスイスイ'),('スウスウスウスウスウ');
+INSERT INTO `縺ゅ≠縺A VALUES ('縺ゅ≠縺ゅ≠縺'),('縺縺縺縺縺'),('縺縺縺縺縺');
+INSERT INTO `鮴夜セ夜セ冒 VALUES ('荳ゆクゆクゆクゆク'),('荳荳荳荳荳'),('荳荳荳荳荳');
+
+ALTER TABLE `スアスアスア` ADD `スカスカスカ` char(1) FIRST;
+ALTER TABLE `スアスアスア` ADD `スクスクスク` char(1) AFTER `スキスキスキ`;
+ALTER TABLE `スアスアスア` ADD `スケスケスケ` char(1);
+ALTER TABLE `スアスアスア` ADD INDEX (`スカスカスカ`);
+ALTER TABLE `スアスアスア` ADD PRIMARY KEY (`スキスキスキ`);
+ALTER TABLE `スアスアスア` ADD UNIQUE (`スクスクスク`);
+#ALTER TABLE `スアスアスア` ADD FOREIGN KEY (`スケスケスケ`) REFERENCES `スイスイスイ`(`スケスケスケ`);
+ALTER TABLE `スアスアスア` CHANGE `スカスカスカ` `スカスカ` char(1);
+ALTER TABLE `スアスアスア` MODIFY `スキスキスキ` char(6);
+
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `スアスアスア` DROP INDEX `スカスカスカ`;
+ALTER TABLE `スアスアスア` DROP PRIMARY KEY;
+ALTER TABLE `スアスアスア` DROP INDEX `スクスクスク`;
+#ALTER TABLE `スアスアスア` DROP FOREIGN KEY `スケスケスケ`;
+ALTER TABLE `スアスアスア` DROP `スカスカ`;
+ALTER TABLE `スアスアスア` DROP `スクスクスク`;
+ALTER TABLE `スアスアスア` DROP `スケスケスケ`;
+SELECT * FROM `スアスアスア`;
+DESC `スアスアスア`;
+SHOW CREATE TABLE `スアスアスア`;
+
+ALTER TABLE `縺ゅ≠縺A ADD `縺九°縺義 char(1) FIRST;
+ALTER TABLE `縺ゅ≠縺A ADD `縺上¥縺汁 char(1) AFTER `縺阪″縺港;
+ALTER TABLE `縺ゅ≠縺A ADD `縺代¢縺疏 char(1);
+ALTER TABLE `縺ゅ≠縺A ADD INDEX (`縺九°縺義);
+ALTER TABLE `縺ゅ≠縺A ADD PRIMARY KEY (`縺阪″縺港);
+ALTER TABLE `縺ゅ≠縺A ADD UNIQUE (`縺上¥縺汁);
+#ALTER TABLE `縺ゅ≠縺A ADD FOREIGN KEY (`縺代¢縺疏) REFERENCES `縺縺縺Я(`縺代¢縺疏);
+ALTER TABLE `縺ゅ≠縺A CHANGE `縺九°縺義 `縺九°` char(1);
+ALTER TABLE `縺ゅ≠縺A MODIFY `縺阪″縺港 char(6);
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺九°縺義;
+ALTER TABLE `縺ゅ≠縺A DROP PRIMARY KEY;
+ALTER TABLE `縺ゅ≠縺A DROP INDEX `縺上¥縺汁;
+#ALTER TABLE `縺ゅ≠縺A DROP FOREIGN KEY `縺代¢縺疏;
+ALTER TABLE `縺ゅ≠縺A DROP `縺九°`;
+ALTER TABLE `縺ゅ≠縺A DROP `縺上¥縺汁;
+ALTER TABLE `縺ゅ≠縺A DROP `縺代¢縺疏;
+
+SELECT * FROM `縺ゅ≠縺A;
+DESC `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳Я char(1) FIRST;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荳荳荳` char(1) AFTER `荳ゆクゆクA;
+ALTER TABLE `鮴夜セ夜セ冒 ADD `荵壻ケ壻ケ啻 char(1);
+ALTER TABLE `鮴夜セ夜セ冒 ADD INDEX (`荳荳荳Я);
+ALTER TABLE `鮴夜セ夜セ冒 ADD PRIMARY KEY (`荳ゆクゆクA);
+ALTER TABLE `鮴夜セ夜セ冒 ADD UNIQUE (`荳荳荳`);
+#ALTER TABLE `鮴夜セ夜セ冒 ADD FOREIGN KEY (`荵壻ケ壻ケ啻) REFERENCES `鮴鈴セ鈴セ輿(`荵壻ケ壻ケ啻);
+ALTER TABLE `鮴夜セ夜セ冒 CHANGE `荳荳荳Я `荳荳Я char(1);
+ALTER TABLE `鮴夜セ夜セ冒 MODIFY `荳ゆクゆクA char(6);
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP PRIMARY KEY;
+ALTER TABLE `鮴夜セ夜セ冒 DROP INDEX `荳荳荳`;
+#ALTER TABLE `鮴夜セ夜セ冒 DROP FOREIGN KEY `荵壻ケ壻ケ啻;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳Я;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荳荳荳`;
+ALTER TABLE `鮴夜セ夜セ冒 DROP `荵壻ケ壻ケ啻;
+
+SELECT * FROM `鮴夜セ夜セ冒;
+DESC `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
diff --git a/mysql-test/suite/jp/t/jp_charlength_sjis.test b/mysql-test/suite/jp/t/jp_charlength_sjis.test
new file mode 100644
index 00000000..91bdb272
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charlength_sjis.test
@@ -0,0 +1,66 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test CHAR_LENGTH() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T1`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T2`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T4`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T5`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T7`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T8`;
+SELECT `C1`, CHAR_LENGTH(`C1`) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_charlength_ucs2.test b/mysql-test/suite/jp/t/jp_charlength_ucs2.test
new file mode 100644
index 00000000..4376ebbd
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charlength_ucs2.test
@@ -0,0 +1,67 @@
+--source include/have_ucs2.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 CHAR_LENGTH() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_charlength_ujis.test b/mysql-test/suite/jp/t/jp_charlength_ujis.test
new file mode 100644
index 00000000..3f55e8ee
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charlength_ujis.test
@@ -0,0 +1,66 @@
+--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 CHAR_LENGTH() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CHAR_LENGTH(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_charlength_utf8.test b/mysql-test/suite/jp/t/jp_charlength_utf8.test
new file mode 100644
index 00000000..9e88bd98
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charlength_utf8.test
@@ -0,0 +1,65 @@
+--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 CHAR_LENGTH() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ疏;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ蛋;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ覗;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ描;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ輿;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ倭;
+SELECT `シ」シ疏, CHAR_LENGTH(`シ」シ疏) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_charset_sjis.test b/mysql-test/suite/jp/t/jp_charset_sjis.test
new file mode 100644
index 00000000..4cde0848
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charset_sjis.test
@@ -0,0 +1,109 @@
+--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
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test CHARSET() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(20)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(20)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(20)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(20)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(20)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(20)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(20)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(20)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(20)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+#Load the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T1`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T2`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T3`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T4`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T5`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T6`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T7`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T8`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T9`;
+
+#InnoDB
+SELECT DISTINCT CHARSET(`C1`) FROM `T1`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T2`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T3`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T1`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T1`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T1`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T1`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T2`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T2`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T2`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T2`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T3`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T3`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T3`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T3`;
+
+#MyISAM
+SELECT DISTINCT CHARSET(`C1`) FROM `T4`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T5`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T6`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T4`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T4`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T4`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T4`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T5`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T5`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T5`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T5`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T6`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T6`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T6`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T6`;
+
+#MEMORY
+SELECT DISTINCT CHARSET(`C1`) FROM `T7`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T8`;
+SELECT DISTINCT CHARSET(`C1`) FROM `T9`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T7`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T7`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T7`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T7`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T8`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T8`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T8`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T8`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING utf8)) FROM `T9`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ucs2)) FROM `T9`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING sjis)) FROM `T9`;
+SELECT DISTINCT CHARSET(CONVERT(`C1` USING ujis)) FROM `T9`;
+
+drop table `T1`;
+drop table `T2`;
+drop table `T3`;
+drop table `T4`;
+drop table `T5`;
+drop table `T6`;
+drop table `T7`;
+drop table `T8`;
+drop table `T9`;
diff --git a/mysql-test/suite/jp/t/jp_charset_ucs2.test b/mysql-test/suite/jp/t/jp_charset_ucs2.test
new file mode 100644
index 00000000..8427d721
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charset_ucs2.test
@@ -0,0 +1,174 @@
+--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 CHARSET() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+#Insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `」ヤ」ア` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」イ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ウ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」エ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」オ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」カ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」キ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」ク` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ケ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+#InnoDB
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ケ`;
+
+drop table `」ヤ」ア`;
+drop table `」ヤ」イ`;
+drop table `」ヤ」ウ`;
+drop table `」ヤ」エ`;
+drop table `」ヤ」オ`;
+drop table `」ヤ」カ`;
+drop table `」ヤ」キ`;
+drop table `」ヤ」ク`;
+drop table `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_charset_ujis.test b/mysql-test/suite/jp/t/jp_charset_ujis.test
new file mode 100644
index 00000000..6e80162c
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charset_ujis.test
@@ -0,0 +1,110 @@
+--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 CHARSET() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20)) DEFAULT CHARSET = ujis 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_ujis.dat' INTO TABLE `」ヤ」ア`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」イ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ウ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」エ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」オ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」カ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」キ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」ク`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ケ`;
+
+#InnoDB
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ア`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」イ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ウ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」エ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」オ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」カ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(`」テ」ア`) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」キ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ク`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING utf8)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ucs2)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING sjis)) FROM `」ヤ」ケ`;
+SELECT DISTINCT CHARSET(CONVERT(`」テ」ア` USING ujis)) FROM `」ヤ」ケ`;
+
+drop table `」ヤ」ア`;
+drop table `」ヤ」イ`;
+drop table `」ヤ」ウ`;
+drop table `」ヤ」エ`;
+drop table `」ヤ」オ`;
+drop table `」ヤ」カ`;
+drop table `」ヤ」キ`;
+drop table `」ヤ」ク`;
+drop table `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_charset_utf8.test b/mysql-test/suite/jp/t/jp_charset_utf8.test
new file mode 100644
index 00000000..e02c035f
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_charset_utf8.test
@@ -0,0 +1,110 @@
+--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 CHARSET() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(20)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(20)) 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 DISTINCT CHARSET(`シ」シ疏) FROM `シエシ疏;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ蛋;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ伝;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ疏;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ疏;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ疏;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ疏;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ蛋;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ蛋;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ蛋;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ蛋;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ伝;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ伝;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ伝;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ伝;
+
+#MyISAM
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ覗;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ描;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ冒;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ覗;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ覗;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ覗;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ覗;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ描;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ描;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ描;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ描;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ冒;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ冒;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ冒;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ冒;
+
+#MEMORY
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ輿;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ倭;
+SELECT DISTINCT CHARSET(`シ」シ疏) FROM `シエシ兪;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ輿;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ輿;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ輿;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ輿;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ倭;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ倭;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ倭;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ倭;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING utf8)) FROM `シエシ兪;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ucs2)) FROM `シエシ兪;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING sjis)) FROM `シエシ兪;
+SELECT DISTINCT CHARSET(CONVERT(`シ」シ疏 USING ujis)) FROM `シエシ兪;
+
+drop table `シエシ疏;
+drop table `シエシ蛋;
+drop table `シエシ伝;
+drop table `シエシ覗;
+drop table `シエシ描;
+drop table `シエシ冒;
+drop table `シエシ輿;
+drop table `シエシ倭;
+drop table `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_convert_sjis.test b/mysql-test/suite/jp/t/jp_convert_sjis.test
new file mode 100644
index 00000000..ccbce35b
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_convert_sjis.test
@@ -0,0 +1,93 @@
+--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
+
+--character_set sjis
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test CONVERT() function with Japanese character in sjis encoding
+#
+
+CREATE TABLE `T1` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis 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_sjis.dat' INTO TABLE `T1`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T2`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T3`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T4`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T5`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T6`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T7`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T8`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T9`;
+
+#InnoDB
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T1`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T1`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T1`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T2`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T2`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T2`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T3`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T3`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T4`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T4`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T4`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T5`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T5`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T5`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T6`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T6`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T7`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T7`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T7`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T8`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T8`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T8`;
+SELECT `C1`, CONVERT(`C1` using utf8) FROM `T9`;
+SELECT `C1`, CONVERT(`C1` using ucs2) FROM `T9`;
+SELECT `C1`, CONVERT(`C1` using ujis) FROM `T9`;
+
+drop table `T1`;
+drop table `T2`;
+drop table `T3`;
+drop table `T4`;
+drop table `T5`;
+drop table `T6`;
+drop table `T7`;
+drop table `T8`;
+drop table `T9`;
diff --git a/mysql-test/suite/jp/t/jp_convert_ucs2.test b/mysql-test/suite/jp/t/jp_convert_ucs2.test
new file mode 100644
index 00000000..cf796223
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_convert_ucs2.test
@@ -0,0 +1,161 @@
+--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 ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+#Insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `」ヤ」ア` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」イ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ウ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」エ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」オ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」カ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」キ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」ク` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ケ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+#InnoDB
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 utf8) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 utf8) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_convert_ujis.test b/mysql-test/suite/jp/t/jp_convert_ujis.test
new file mode 100644
index 00000000..f15fee49
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_convert_ujis.test
@@ -0,0 +1,95 @@
+--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 ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis 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_ujis.dat' INTO TABLE `」ヤ」ア`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」イ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ウ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」エ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」オ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」カ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」キ`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」ク`;
+ LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ケ`;
+
+#InnoDB
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 utf8) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 utf8) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using ucs2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using sjis) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, CONVERT(`」テ」ア` using utf8) 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 `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_convert_utf8.test b/mysql-test/suite/jp/t/jp_convert_utf8.test
new file mode 100644
index 00000000..7a230495
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_convert_utf8.test
@@ -0,0 +1,94 @@
+--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 `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_create_db_sjis.test b/mysql-test/suite/jp/t/jp_create_db_sjis.test
new file mode 100644
index 00000000..5458e6f0
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_db_sjis.test
@@ -0,0 +1,27 @@
+--source include/have_sjis.inc
+--character_set sjis
+SET NAMES sjis;
+SET character_set_database = sjis;
+--disable_warnings
+drop database if exists `ニホンゴ`;
+drop database if exists `日本語`;
+drop database if exists `ソ十表`;
+--enable_warnings
+
+#
+# Test Creating databases using Japanese charact for DB name in ujis encoding
+#
+
+CREATE DATABASE `ニホンゴ`;
+CREATE DATABASE `日本語`;
+CREATE DATABASE `ソ十表`;
+
+SELECT schema_name from information_schema.schemata where schema_name <> 'mtr' ORDER BY schema_name;
+
+USE `ニホンゴ`;
+USE `日本語`;
+USE `ソ十表`;
+
+DROP DATABASE `ニホンゴ`;
+DROP DATABASE `日本語`;
+DROP DATABASE `ソ十表`;
diff --git a/mysql-test/suite/jp/t/jp_create_db_ucs2.test b/mysql-test/suite/jp/t/jp_create_db_ucs2.test
new file mode 100644
index 00000000..a3f64d1e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_db_ucs2.test
@@ -0,0 +1,29 @@
+--source include/have_ucs2.inc
+
+--disable_warnings
+drop database if exists `屡斜爵室酌`;
+drop database if exists `ニヒワク`;
+drop database if exists `常ワ常ン常゙`;
+--enable_warnings
+
+#
+# Test Creating databases using Japanese charact for DB name in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET character_set_server = ucs2;
+
+CREATE DATABASE `屡斜爵室酌`;
+CREATE DATABASE `ニヒワク`;
+CREATE DATABASE `常ワ常ン常゙`;
+
+SELECT schema_name from information_schema.schemata where schema_name <> 'mtr' ORDER BY schema_name;
+
+USE `屡斜爵室酌`;
+USE `ニヒワク`;
+USE `常ワ常ン常゙`;
+
+DROP DATABASE `屡斜爵室酌`;
+DROP DATABASE `ニヒワク`;
+DROP DATABASE `常ワ常ン常゙`;
diff --git a/mysql-test/suite/jp/t/jp_create_db_ujis.test b/mysql-test/suite/jp/t/jp_create_db_ujis.test
new file mode 100644
index 00000000..514745aa
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_db_ujis.test
@@ -0,0 +1,28 @@
+--source include/have_ujis.inc
+
+--disable_warnings
+drop database if exists `屡斜爵室酌`;
+drop database if exists `ニヒワク`;
+drop database if exists `常ワ常ン常゙`;
+--enable_warnings
+
+#
+# Test Creating databases using Japanese charact for DB name in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE DATABASE `屡斜爵室酌`;
+CREATE DATABASE `ニヒワク`;
+CREATE DATABASE `常ワ常ン常゙`;
+
+SELECT schema_name from information_schema.schemata where schema_name <> 'mtr' ORDER BY schema_name;
+
+USE `屡斜爵室酌`;
+USE `ニヒワク`;
+USE `常ワ常ン常゙`;
+
+DROP DATABASE `屡斜爵室酌`;
+DROP DATABASE `ニヒワク`;
+DROP DATABASE `常ワ常ン常゙`;
diff --git a/mysql-test/suite/jp/t/jp_create_db_utf8.test b/mysql-test/suite/jp/t/jp_create_db_utf8.test
new file mode 100644
index 00000000..8617af57
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_db_utf8.test
@@ -0,0 +1,27 @@
+--source include/have_utf8.inc
+--disable_warnings
+drop database if exists `セセ趣セ晢スコセ杼;
+drop database if exists `譌・譛ャ隱杼;
+drop database if exists `鮴秘セ夜セ輿;
+--enable_warnings
+
+#
+# Test Creating databases using Japanese charact for DB name in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE DATABASE `セセ趣セ晢スコセ杼;
+CREATE DATABASE `譌・譛ャ隱杼;
+CREATE DATABASE `鮴秘セ夜セ輿;
+
+SELECT schema_name from information_schema.schemata where schema_name <> 'mtr' ORDER BY schema_name;
+
+USE `セセ趣セ晢スコセ杼;
+USE `譌・譛ャ隱杼;
+USE `鮴秘セ夜セ輿;
+
+DROP DATABASE `セセ趣セ晢スコセ杼;
+DROP DATABASE `譌・譛ャ隱杼;
+DROP DATABASE `鮴秘セ夜セ輿;
diff --git a/mysql-test/suite/jp/t/jp_create_tbl_sjis.test b/mysql-test/suite/jp/t/jp_create_tbl_sjis.test
new file mode 100644
index 00000000..3a799958
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_tbl_sjis.test
@@ -0,0 +1,238 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+SET NAMES sjis;
+SET character_set_database = sjis;
+--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 `十十十`;
+DROP TABLE IF EXISTS `表表表`;
+DROP TABLE IF EXISTS `予予予`;
+DROP TABLE IF EXISTS `構構構`;
+--enable_warnings
+
+CREATE TABLE `アアア`(`カカカ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `アアア`(`カカカ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `ウウウ`(`ククク` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `ううう`(`くくく` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `表表表`(`申申申`char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `エエエ`(`ケケケ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `オオオ`(`コココ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `えええ`(`けけけ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `おおお`(`こここ` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `予予予`(`貼貼貼` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+CREATE TEMPORARY TABLE `構構構`(`能能能` char(1)) DEFAULT CHARSET = sjis engine=INNODB;
+
+DESC `アアア`;
+DESC `イイイ`;
+DESC `ウウウ`;
+DESC `エエエ`;
+DESC `オオオ`;
+DESC `あああ`;
+DESC `いいい`;
+DESC `ううう`;
+DESC `えええ`;
+DESC `おおお`;
+DESC `ソソソ`;
+DESC `十十十`;
+DESC `表表表`;
+DESC `予予予`;
+DESC `構構構`;
+
+SHOW CREATE TABLE `アアア`;
+SHOW CREATE TABLE `イイイ`;
+SHOW CREATE TABLE `ウウウ`;
+SHOW CREATE TABLE `エエエ`;
+SHOW CREATE TABLE `オオオ`;
+SHOW CREATE TABLE `あああ`;
+SHOW CREATE TABLE `いいい`;
+SHOW CREATE TABLE `ううう`;
+SHOW CREATE TABLE `えええ`;
+SHOW CREATE TABLE `おおお`;
+SHOW CREATE TABLE `ソソソ`;
+SHOW CREATE TABLE `十十十`;
+SHOW CREATE TABLE `表表表`;
+SHOW CREATE TABLE `予予予`;
+SHOW CREATE TABLE `構構構`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `ウウウ`;
+DROP TABLE `エエエ`;
+DROP TABLE `オオオ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ううう`;
+DROP TABLE `えええ`;
+DROP TABLE `おおお`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
+DROP TABLE `表表表`;
+DROP TABLE `予予予`;
+DROP TABLE `構構構`;
+
+CREATE TABLE `アアア`(`カカカ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `アアア`(`カカカ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `ウウウ`(`ククク` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `ううう`(`くくく` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `表表表`(`申申申`char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `エエエ`(`ケケケ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `オオオ`(`コココ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `えええ`(`けけけ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `おおお`(`こここ` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `予予予`(`貼貼貼` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+CREATE TEMPORARY TABLE `構構構`(`能能能` char(1)) DEFAULT CHARSET = sjis engine=MyISAM;
+
+DESC `アアア`;
+DESC `イイイ`;
+DESC `ウウウ`;
+DESC `エエエ`;
+DESC `オオオ`;
+DESC `あああ`;
+DESC `いいい`;
+DESC `ううう`;
+DESC `えええ`;
+DESC `おおお`;
+DESC `ソソソ`;
+DESC `十十十`;
+DESC `表表表`;
+DESC `予予予`;
+DESC `構構構`;
+
+SHOW CREATE TABLE `アアア`;
+SHOW CREATE TABLE `イイイ`;
+SHOW CREATE TABLE `ウウウ`;
+SHOW CREATE TABLE `エエエ`;
+SHOW CREATE TABLE `オオオ`;
+SHOW CREATE TABLE `あああ`;
+SHOW CREATE TABLE `いいい`;
+SHOW CREATE TABLE `ううう`;
+SHOW CREATE TABLE `えええ`;
+SHOW CREATE TABLE `おおお`;
+SHOW CREATE TABLE `ソソソ`;
+SHOW CREATE TABLE `十十十`;
+SHOW CREATE TABLE `表表表`;
+SHOW CREATE TABLE `予予予`;
+SHOW CREATE TABLE `構構構`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `ウウウ`;
+DROP TABLE `エエエ`;
+DROP TABLE `オオオ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ううう`;
+DROP TABLE `えええ`;
+DROP TABLE `おおお`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
+DROP TABLE `表表表`;
+DROP TABLE `予予予`;
+DROP TABLE `構構構`;
+
+CREATE TABLE `アアア`(`カカカ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `アアア`(`カカカ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `イイイ`(`キキキ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `あああ`(`かかか` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `いいい`(`ききき` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `ソソソ`(`噂噂噂` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `十十十`(`蚕蚕蚕` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `ウウウ`(`ククク` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `ううう`(`くくく` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `表表表`(`申申申`char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `エエエ`(`ケケケ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `オオオ`(`コココ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `えええ`(`けけけ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `おおお`(`こここ` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `予予予`(`貼貼貼` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+CREATE TEMPORARY TABLE `構構構`(`能能能` char(1)) DEFAULT CHARSET = sjis engine=MEMORY;
+
+DESC `アアア`;
+DESC `イイイ`;
+DESC `ウウウ`;
+DESC `エエエ`;
+DESC `オオオ`;
+DESC `あああ`;
+DESC `いいい`;
+DESC `ううう`;
+DESC `えええ`;
+DESC `おおお`;
+DESC `ソソソ`;
+DESC `十十十`;
+DESC `表表表`;
+DESC `予予予`;
+DESC `構構構`;
+
+SHOW CREATE TABLE `アアア`;
+SHOW CREATE TABLE `イイイ`;
+SHOW CREATE TABLE `ウウウ`;
+SHOW CREATE TABLE `エエエ`;
+SHOW CREATE TABLE `オオオ`;
+SHOW CREATE TABLE `あああ`;
+SHOW CREATE TABLE `いいい`;
+SHOW CREATE TABLE `ううう`;
+SHOW CREATE TABLE `えええ`;
+SHOW CREATE TABLE `おおお`;
+SHOW CREATE TABLE `ソソソ`;
+SHOW CREATE TABLE `十十十`;
+SHOW CREATE TABLE `表表表`;
+SHOW CREATE TABLE `予予予`;
+SHOW CREATE TABLE `構構構`;
+
+DROP TABLE `アアア`;
+DROP TABLE `イイイ`;
+DROP TABLE `ウウウ`;
+DROP TABLE `エエエ`;
+DROP TABLE `オオオ`;
+DROP TABLE `あああ`;
+DROP TABLE `いいい`;
+DROP TABLE `ううう`;
+DROP TABLE `えええ`;
+DROP TABLE `おおお`;
+DROP TABLE `ソソソ`;
+DROP TABLE `十十十`;
+DROP TABLE `表表表`;
+DROP TABLE `予予予`;
+DROP TABLE `構構構`;
diff --git a/mysql-test/suite/jp/t/jp_create_tbl_ucs2.test b/mysql-test/suite/jp/t/jp_create_tbl_ucs2.test
new file mode 100644
index 00000000..986cc50b
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_tbl_ucs2.test
@@ -0,0 +1,243 @@
+--source include/have_ucs2.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 `、ィ、ィ、ィ`;
+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 creating table with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ucs2 engine=INNODB;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ucs2 engine=MyISAM;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ucs2 engine=MEMORY;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
diff --git a/mysql-test/suite/jp/t/jp_create_tbl_ujis.test b/mysql-test/suite/jp/t/jp_create_tbl_ujis.test
new file mode 100644
index 00000000..c82d1186
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_tbl_ujis.test
@@ -0,0 +1,243 @@
+--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 `、ィ、ィ、ィ`;
+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 creating table with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ujis engine=INNODB;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ujis engine=MyISAM;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
+
+CREATE TABLE `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `竺竺竺`(`叱叱叱` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `軸軸軸`(`執執執` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、「、「、「`(`、ォ、ォ、ォ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、、、、、、`(`、ュ、ュ、ュ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常ン常ン常ン`(`床。床。床。` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常゙常゙常゙`(`床「床「床「` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `宍宍宍`(`失失失` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `、ヲ、ヲ、ヲ`(`、ッ、ッ、ッ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `常゚常゚常゚`(`床」床」床」`char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `雫雫雫`(`嫉嫉嫉` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `七七七`(`室室室` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `、ィ、ィ、ィ`(`、ア、ア、ア` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `、ェ、ェ、ェ`(`、ウ、ウ、ウ` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `常熄熄濮(`床、床、床、` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+CREATE TEMPORARY TABLE `常瘴瘴畫(`床・床・床・` char(1)) DEFAULT CHARSET = ujis engine=MEMORY;
+
+DESC `竺竺竺`;
+DESC `軸軸軸`;
+DESC `宍宍宍`;
+DESC `雫雫雫`;
+DESC `七七七`;
+DESC `、「、「、「`;
+DESC `、、、、、、`;
+DESC `、ヲ、ヲ、ヲ`;
+DESC `、ィ、ィ、ィ`;
+DESC `、ェ、ェ、ェ`;
+DESC `常ン常ン常ン`;
+DESC `常゙常゙常゙`;
+DESC `常゚常゚常゚`;
+DESC `常熄熄濮;
+DESC `常瘴瘴畫;
+
+SHOW CREATE TABLE `竺竺竺`;
+SHOW CREATE TABLE `軸軸軸`;
+SHOW CREATE TABLE `宍宍宍`;
+SHOW CREATE TABLE `雫雫雫`;
+SHOW CREATE TABLE `七七七`;
+SHOW CREATE TABLE `、「、「、「`;
+SHOW CREATE TABLE `、、、、、、`;
+SHOW CREATE TABLE `、ヲ、ヲ、ヲ`;
+SHOW CREATE TABLE `、ィ、ィ、ィ`;
+SHOW CREATE TABLE `、ェ、ェ、ェ`;
+SHOW CREATE TABLE `常ン常ン常ン`;
+SHOW CREATE TABLE `常゙常゙常゙`;
+SHOW CREATE TABLE `常゚常゚常゚`;
+SHOW CREATE TABLE `常熄熄濮;
+SHOW CREATE TABLE `常瘴瘴畫;
+
+DROP TABLE `竺竺竺`;
+DROP TABLE `軸軸軸`;
+DROP TABLE `宍宍宍`;
+DROP TABLE `雫雫雫`;
+DROP TABLE `七七七`;
+DROP TABLE `、「、「、「`;
+DROP TABLE `、、、、、、`;
+DROP TABLE `、ヲ、ヲ、ヲ`;
+DROP TABLE `、ィ、ィ、ィ`;
+DROP TABLE `、ェ、ェ、ェ`;
+DROP TABLE `常ン常ン常ン`;
+DROP TABLE `常゙常゙常゙`;
+DROP TABLE `常゚常゚常゚`;
+DROP TABLE `常熄熄濮;
+DROP TABLE `常瘴瘴畫;
diff --git a/mysql-test/suite/jp/t/jp_create_tbl_utf8.test b/mysql-test/suite/jp/t/jp_create_tbl_utf8.test
new file mode 100644
index 00000000..d079560a
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_create_tbl_utf8.test
@@ -0,0 +1,242 @@
+--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 `縺ゅ≠縺A;
+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 creating table with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `スウスウスウ`(`スクスクスク` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `縺縺縺`(`縺上¥縺汁 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TABLE IF NOT EXISTS `鮴樣セ樣セ杼(`荳荳荳`char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `スエスエスエ`(`スケスケスケ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `スオスオスオ`(`スコスコスコ` char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `縺医∴縺`(`縺代¢縺疏 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `縺翫♀縺柿(`縺薙%縺伝 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `鮴。鮴。鮴。`(`荳御ク御ク形 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+CREATE TEMPORARY TABLE `鮴「鮴「鮴「`(`荳剃ク剃ク蛋 char(1)) DEFAULT CHARSET = utf8 engine=INNODB;
+
+DESC `スアスアスア`;
+DESC `スイスイスイ`;
+DESC `スウスウスウ`;
+DESC `スエスエスエ`;
+DESC `スオスオスオ`;
+DESC `縺ゅ≠縺A;
+DESC `縺縺縺Я;
+DESC `縺縺縺`;
+DESC `縺医∴縺`;
+DESC `縺翫♀縺柿;
+DESC `鮴夜セ夜セ冒;
+DESC `鮴鈴セ鈴セ輿;
+DESC `鮴樣セ樣セ杼;
+DESC `鮴。鮴。鮴。`;
+DESC `鮴「鮴「鮴「`;
+
+SHOW CREATE TABLE `スアスアスア`;
+SHOW CREATE TABLE `スイスイスイ`;
+SHOW CREATE TABLE `スウスウスウ`;
+SHOW CREATE TABLE `スエスエスエ`;
+SHOW CREATE TABLE `スオスオスオ`;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺縺縺Я;
+SHOW CREATE TABLE `縺縺縺`;
+SHOW CREATE TABLE `縺医∴縺`;
+SHOW CREATE TABLE `縺翫♀縺柿;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴鈴セ鈴セ輿;
+SHOW CREATE TABLE `鮴樣セ樣セ杼;
+SHOW CREATE TABLE `鮴。鮴。鮴。`;
+SHOW CREATE TABLE `鮴「鮴「鮴「`;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `スウスウスウ`;
+DROP TABLE `スエスエスエ`;
+DROP TABLE `スオスオスオ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `縺縺縺`;
+DROP TABLE `縺医∴縺`;
+DROP TABLE `縺翫♀縺柿;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
+DROP TABLE `鮴樣セ樣セ杼;
+DROP TABLE `鮴。鮴。鮴。`;
+DROP TABLE `鮴「鮴「鮴「`;
+
+CREATE TABLE `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `スウスウスウ`(`スクスクスク` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `縺縺縺`(`縺上¥縺汁 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TABLE IF NOT EXISTS `鮴樣セ樣セ杼(`荳荳荳`char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `スエスエスエ`(`スケスケスケ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `スオスオスオ`(`スコスコスコ` char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `縺医∴縺`(`縺代¢縺疏 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `縺翫♀縺柿(`縺薙%縺伝 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `鮴。鮴。鮴。`(`荳御ク御ク形 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+CREATE TEMPORARY TABLE `鮴「鮴「鮴「`(`荳剃ク剃ク蛋 char(1)) DEFAULT CHARSET = utf8 engine=MyISAM;
+
+DESC `スアスアスア`;
+DESC `スイスイスイ`;
+DESC `スウスウスウ`;
+DESC `スエスエスエ`;
+DESC `スオスオスオ`;
+DESC `縺ゅ≠縺A;
+DESC `縺縺縺Я;
+DESC `縺縺縺`;
+DESC `縺医∴縺`;
+DESC `縺翫♀縺柿;
+DESC `鮴夜セ夜セ冒;
+DESC `鮴鈴セ鈴セ輿;
+DESC `鮴樣セ樣セ杼;
+DESC `鮴。鮴。鮴。`;
+DESC `鮴「鮴「鮴「`;
+
+SHOW CREATE TABLE `スアスアスア`;
+SHOW CREATE TABLE `スイスイスイ`;
+SHOW CREATE TABLE `スウスウスウ`;
+SHOW CREATE TABLE `スエスエスエ`;
+SHOW CREATE TABLE `スオスオスオ`;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺縺縺Я;
+SHOW CREATE TABLE `縺縺縺`;
+SHOW CREATE TABLE `縺医∴縺`;
+SHOW CREATE TABLE `縺翫♀縺柿;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴鈴セ鈴セ輿;
+SHOW CREATE TABLE `鮴樣セ樣セ杼;
+SHOW CREATE TABLE `鮴。鮴。鮴。`;
+SHOW CREATE TABLE `鮴「鮴「鮴「`;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `スウスウスウ`;
+DROP TABLE `スエスエスエ`;
+DROP TABLE `スオスオスオ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `縺縺縺`;
+DROP TABLE `縺医∴縺`;
+DROP TABLE `縺翫♀縺柿;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
+DROP TABLE `鮴樣セ樣セ杼;
+DROP TABLE `鮴。鮴。鮴。`;
+DROP TABLE `鮴「鮴「鮴「`;
+
+CREATE TABLE `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+# Tables should not be created because table names exist
+CREATE TABLE IF NOT EXISTS `スアスアスア`(`スカスカスカ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `スイスイスイ`(`スキスキスキ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `縺ゅ≠縺A(`縺九°縺義 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `縺縺縺Я(`縺阪″縺港 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `鮴夜セ夜セ冒(`荳ゆクゆクA char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `鮴鈴セ鈴セ輿(`荳荳荳Я char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+# Tables should be created
+CREATE TABLE IF NOT EXISTS `スウスウスウ`(`スクスクスク` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `縺縺縺`(`縺上¥縺汁 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TABLE IF NOT EXISTS `鮴樣セ樣セ杼(`荳荳荳`char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `スエスエスエ`(`スケスケスケ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `スオスオスオ`(`スコスコスコ` char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `縺医∴縺`(`縺代¢縺疏 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `縺翫♀縺柿(`縺薙%縺伝 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `鮴。鮴。鮴。`(`荳御ク御ク形 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+CREATE TEMPORARY TABLE `鮴「鮴「鮴「`(`荳剃ク剃ク蛋 char(1)) DEFAULT CHARSET = utf8 engine=MEMORY;
+
+DESC `スアスアスア`;
+DESC `スイスイスイ`;
+DESC `スウスウスウ`;
+DESC `スエスエスエ`;
+DESC `スオスオスオ`;
+DESC `縺ゅ≠縺A;
+DESC `縺縺縺Я;
+DESC `縺縺縺`;
+DESC `縺医∴縺`;
+DESC `縺翫♀縺柿;
+DESC `鮴夜セ夜セ冒;
+DESC `鮴鈴セ鈴セ輿;
+DESC `鮴樣セ樣セ杼;
+DESC `鮴。鮴。鮴。`;
+DESC `鮴「鮴「鮴「`;
+
+SHOW CREATE TABLE `スアスアスア`;
+SHOW CREATE TABLE `スイスイスイ`;
+SHOW CREATE TABLE `スウスウスウ`;
+SHOW CREATE TABLE `スエスエスエ`;
+SHOW CREATE TABLE `スオスオスオ`;
+SHOW CREATE TABLE `縺ゅ≠縺A;
+SHOW CREATE TABLE `縺縺縺Я;
+SHOW CREATE TABLE `縺縺縺`;
+SHOW CREATE TABLE `縺医∴縺`;
+SHOW CREATE TABLE `縺翫♀縺柿;
+SHOW CREATE TABLE `鮴夜セ夜セ冒;
+SHOW CREATE TABLE `鮴鈴セ鈴セ輿;
+SHOW CREATE TABLE `鮴樣セ樣セ杼;
+SHOW CREATE TABLE `鮴。鮴。鮴。`;
+SHOW CREATE TABLE `鮴「鮴「鮴「`;
+
+DROP TABLE `スアスアスア`;
+DROP TABLE `スイスイスイ`;
+DROP TABLE `スウスウスウ`;
+DROP TABLE `スエスエスエ`;
+DROP TABLE `スオスオスオ`;
+DROP TABLE `縺ゅ≠縺A;
+DROP TABLE `縺縺縺Я;
+DROP TABLE `縺縺縺`;
+DROP TABLE `縺医∴縺`;
+DROP TABLE `縺翫♀縺柿;
+DROP TABLE `鮴夜セ夜セ冒;
+DROP TABLE `鮴鈴セ鈴セ輿;
+DROP TABLE `鮴樣セ樣セ杼;
+DROP TABLE `鮴。鮴。鮴。`;
+DROP TABLE `鮴「鮴「鮴「`;
diff --git a/mysql-test/suite/jp/t/jp_enum_sjis.test b/mysql-test/suite/jp/t/jp_enum_sjis.test
new file mode 100644
index 00000000..1060f83e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_enum_sjis.test
@@ -0,0 +1,130 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+drop table if exists t1;
+--enable_warnings
+
+#
+# Test ENUM values with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` ENUM('ア','イ','ウ'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` ENUM('あ','い','う'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` ENUM('ソ','十','表'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` ENUM('ア','イ','ウ'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` ENUM('あ','い','う'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` ENUM('ソ','十','表'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` ENUM('ア','イ','ウ'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` ENUM('あ','い','う'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` ENUM('ソ','十','表'), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('ア'),('イ'),('ウ');
+INSERT INTO `T2` VALUES ('あ'),('い'),('う');
+INSERT INTO `T3` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T4` VALUES ('ア'),('イ'),('ウ');
+INSERT INTO `T5` VALUES ('あ'),('い'),('う');
+INSERT INTO `T6` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T7` VALUES ('ア'),('イ'),('ウ');
+INSERT INTO `T8` VALUES ('あ'),('い'),('う');
+INSERT INTO `T9` VALUES ('ソ'),('十'),('表');
+
+SELECT * FROM `T1`;
+SELECT * FROM `T2`;
+SELECT * FROM `T3`;
+SELECT * FROM `T4`;
+SELECT * FROM `T5`;
+SELECT * FROM `T6`;
+SELECT * FROM `T7`;
+SELECT * FROM `T8`;
+SELECT * FROM `T9`;
+
+SHOW CREATE TABLE `T1`;
+SHOW CREATE TABLE `T2`;
+SHOW CREATE TABLE `T3`;
+SHOW CREATE TABLE `T4`;
+SHOW CREATE TABLE `T5`;
+SHOW CREATE TABLE `T6`;
+SHOW CREATE TABLE `T7`;
+SHOW CREATE TABLE `T8`;
+SHOW CREATE TABLE `T9`;
+
+DESC `T1`;
+DESC `T2`;
+DESC `T3`;
+DESC `T4`;
+DESC `T5`;
+DESC `T6`;
+DESC `T7`;
+DESC `T8`;
+DESC `T9`;
+
+#
+# Test problem with enum values after the colum with NOT NULL restriction
+#
+
+ALTER TABLE `T1` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T2` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T3` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T4` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T5` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T6` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T7` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T8` ADD `C2` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `T9` ADD `C2` CHAR(1) NOT NULL FIRST;
+
+SHOW CREATE TABLE `T1`;
+SHOW CREATE TABLE `T2`;
+SHOW CREATE TABLE `T3`;
+SHOW CREATE TABLE `T4`;
+SHOW CREATE TABLE `T5`;
+SHOW CREATE TABLE `T6`;
+SHOW CREATE TABLE `T7`;
+SHOW CREATE TABLE `T8`;
+SHOW CREATE TABLE `T9`;
+
+#
+# Test to distinguish 0x9353 and 0x9373
+# Bug#6206 ENUMs are not case sensitive even if declared BINARY
+#
+
+CREATE TABLE t1(c1 enum('鉄','都')) default character set = sjis;
+INSERT INTO t1 VALUES('鉄'),('都');
+SELECT * FROM t1 WHERE c1 LIKE '鉄';
+DROP TABLE t1;
+
+DESC `T1`;
+DESC `T2`;
+DESC `T3`;
+DESC `T4`;
+DESC `T5`;
+DESC `T6`;
+DESC `T7`;
+DESC `T8`;
+DESC `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_enum_ucs2.test b/mysql-test/suite/jp/t/jp_enum_ucs2.test
new file mode 100644
index 00000000..321f8952
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_enum_ucs2.test
@@ -0,0 +1,123 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
+--source include/have_ucs2.inc
+--source include/have_innodb.inc
+
+# half-with kana is not handled correctly in 4.1
+# because of bug #5174
+# It will be fixed in 5.0
+
+--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 ENUM values with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 ('常ワ'),('常ン'),('常゙');
+
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+SHOW CREATE TABLE `」ヤ」ア`;
+SHOW CREATE TABLE `」ヤ」イ`;
+SHOW CREATE TABLE `」ヤ」ウ`;
+SHOW CREATE TABLE `」ヤ」エ`;
+SHOW CREATE TABLE `」ヤ」オ`;
+SHOW CREATE TABLE `」ヤ」カ`;
+SHOW CREATE TABLE `」ヤ」キ`;
+SHOW CREATE TABLE `」ヤ」ク`;
+SHOW CREATE TABLE `」ヤ」ケ`;
+
+DESC `」ヤ」ア`;
+DESC `」ヤ」イ`;
+DESC `」ヤ」ウ`;
+DESC `」ヤ」エ`;
+DESC `」ヤ」オ`;
+DESC `」ヤ」カ`;
+DESC `」ヤ」キ`;
+DESC `」ヤ」ク`;
+DESC `」ヤ」ケ`;
+
+#
+# Test problem with enum values after the colum with NOT NULL restriction
+# Bug#7302 UCS2 data in ENUM field get truncated when new column is added
+ALTER TABLE `」ヤ」ア` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」イ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ウ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」エ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」オ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」カ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」キ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ク` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ケ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+
+SHOW CREATE TABLE `」ヤ」ア`;
+SHOW CREATE TABLE `」ヤ」イ`;
+SHOW CREATE TABLE `」ヤ」ウ`;
+SHOW CREATE TABLE `」ヤ」エ`;
+SHOW CREATE TABLE `」ヤ」オ`;
+SHOW CREATE TABLE `」ヤ」カ`;
+SHOW CREATE TABLE `」ヤ」キ`;
+SHOW CREATE TABLE `」ヤ」ク`;
+SHOW CREATE TABLE `」ヤ」ケ`;
+
+DESC `」ヤ」ア`;
+DESC `」ヤ」イ`;
+DESC `」ヤ」ウ`;
+DESC `」ヤ」エ`;
+DESC `」ヤ」オ`;
+DESC `」ヤ」カ`;
+DESC `」ヤ」キ`;
+DESC `」ヤ」ク`;
+DESC `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_enum_ujis.test b/mysql-test/suite/jp/t/jp_enum_ujis.test
new file mode 100644
index 00000000..10e8ad55
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_enum_ujis.test
@@ -0,0 +1,119 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
+--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 ENUM values with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` ENUM('竺','軸','宍'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` ENUM('、「','、、','、ヲ'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` ENUM('常ワ','常ン','常゙'), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 ('常ワ'),('常ン'),('常゙');
+
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+SHOW CREATE TABLE `」ヤ」ア`;
+SHOW CREATE TABLE `」ヤ」イ`;
+SHOW CREATE TABLE `」ヤ」ウ`;
+SHOW CREATE TABLE `」ヤ」エ`;
+SHOW CREATE TABLE `」ヤ」オ`;
+SHOW CREATE TABLE `」ヤ」カ`;
+SHOW CREATE TABLE `」ヤ」キ`;
+SHOW CREATE TABLE `」ヤ」ク`;
+SHOW CREATE TABLE `」ヤ」ケ`;
+
+DESC `」ヤ」ア`;
+DESC `」ヤ」イ`;
+DESC `」ヤ」ウ`;
+DESC `」ヤ」エ`;
+DESC `」ヤ」オ`;
+DESC `」ヤ」カ`;
+DESC `」ヤ」キ`;
+DESC `」ヤ」ク`;
+DESC `」ヤ」ケ`;
+
+#
+# Test problem with enum values after the colum with NOT NULL restriction
+#
+
+ALTER TABLE `」ヤ」ア` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」イ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ウ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」エ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」オ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」カ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」キ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ク` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+ALTER TABLE `」ヤ」ケ` ADD `」テ」イ` CHAR(1) NOT NULL FIRST;
+
+SHOW CREATE TABLE `」ヤ」ア`;
+SHOW CREATE TABLE `」ヤ」イ`;
+SHOW CREATE TABLE `」ヤ」ウ`;
+SHOW CREATE TABLE `」ヤ」エ`;
+SHOW CREATE TABLE `」ヤ」オ`;
+SHOW CREATE TABLE `」ヤ」カ`;
+SHOW CREATE TABLE `」ヤ」キ`;
+SHOW CREATE TABLE `」ヤ」ク`;
+SHOW CREATE TABLE `」ヤ」ケ`;
+
+DESC `」ヤ」ア`;
+DESC `」ヤ」イ`;
+DESC `」ヤ」ウ`;
+DESC `」ヤ」エ`;
+DESC `」ヤ」オ`;
+DESC `」ヤ」カ`;
+DESC `」ヤ」キ`;
+DESC `」ヤ」ク`;
+DESC `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_enum_utf8.test b/mysql-test/suite/jp/t/jp_enum_utf8.test
new file mode 100644
index 00000000..f67939bd
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_enum_utf8.test
@@ -0,0 +1,118 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.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 ENUM values with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 ENUM('スア','スイ','スウ'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 ENUM('縺','縺','縺'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 ENUM('鮴','鮴','鮴'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 ENUM('スア','スイ','スウ'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 ENUM('縺','縺','縺'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 ENUM('鮴','鮴','鮴'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 ENUM('スア','スイ','スウ'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 ENUM('縺','縺','縺'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 ENUM('鮴','鮴','鮴'), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 ('鮴'),('鮴'),('鮴');
+
+SELECT * FROM `シエシ疏;
+SELECT * FROM `シエシ蛋;
+SELECT * FROM `シエシ伝;
+SELECT * FROM `シエシ覗;
+SELECT * FROM `シエシ描;
+SELECT * FROM `シエシ冒;
+SELECT * FROM `シエシ輿;
+SELECT * FROM `シエシ倭;
+SELECT * FROM `シエシ兪;
+
+SHOW CREATE TABLE `シエシ疏;
+SHOW CREATE TABLE `シエシ蛋;
+SHOW CREATE TABLE `シエシ伝;
+SHOW CREATE TABLE `シエシ覗;
+SHOW CREATE TABLE `シエシ描;
+SHOW CREATE TABLE `シエシ冒;
+SHOW CREATE TABLE `シエシ輿;
+SHOW CREATE TABLE `シエシ倭;
+SHOW CREATE TABLE `シエシ兪;
+
+DESC `シエシ疏;
+DESC `シエシ蛋;
+DESC `シエシ伝;
+DESC `シエシ覗;
+DESC `シエシ描;
+DESC `シエシ冒;
+DESC `シエシ輿;
+DESC `シエシ倭;
+DESC `シエシ兪;
+
+#
+# Test problem with enum values after the colum with NOT NULL restriction
+#
+
+ALTER TABLE `シエシ疏 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ蛋 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ伝 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ覗 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ描 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ冒 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ輿 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ倭 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+ALTER TABLE `シエシ兪 ADD `シ」シ蛋 CHAR(1) NOT NULL FIRST;
+
+SHOW CREATE TABLE `シエシ疏;
+SHOW CREATE TABLE `シエシ蛋;
+SHOW CREATE TABLE `シエシ伝;
+SHOW CREATE TABLE `シエシ覗;
+SHOW CREATE TABLE `シエシ描;
+SHOW CREATE TABLE `シエシ冒;
+SHOW CREATE TABLE `シエシ輿;
+SHOW CREATE TABLE `シエシ倭;
+SHOW CREATE TABLE `シエシ兪;
+
+DESC `シエシ疏;
+DESC `シエシ蛋;
+DESC `シエシ伝;
+DESC `シエシ覗;
+DESC `シエシ描;
+DESC `シエシ冒;
+DESC `シエシ輿;
+DESC `シエシ倭;
+DESC `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_insert_sjis.test b/mysql-test/suite/jp/t/jp_insert_sjis.test
new file mode 100644
index 00000000..957798cb
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_insert_sjis.test
@@ -0,0 +1,282 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test INSERT() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+#InnoDB
+SELECT INSERT(`C1`,1,1,'カ') FROM `T1`;
+SELECT INSERT(`C1`,1,2,'カキ') FROM `T1`;
+SELECT INSERT(`C1`,1,3,'カキク') FROM `T1`;
+SELECT INSERT(`C1`,1,4,'カキクケ') FROM `T1`;
+SELECT INSERT(`C1`,1,5,'カキクケコ') FROM `T1`;
+SELECT INSERT(`C1`,2,1,'キ') FROM `T1`;
+SELECT INSERT(`C1`,2,2,'キク') FROM `T1`;
+SELECT INSERT(`C1`,2,3,'キクケ') FROM `T1`;
+SELECT INSERT(`C1`,2,4,'キクケコ') FROM `T1`;
+SELECT INSERT(`C1`,3,1,'ク') FROM `T1`;
+SELECT INSERT(`C1`,3,2,'クケ') FROM `T1`;
+SELECT INSERT(`C1`,3,3,'クケコ') FROM `T1`;
+SELECT INSERT(`C1`,4,1,'ケ') FROM `T1`;
+SELECT INSERT(`C1`,4,2,'ケコ') FROM `T1`;
+SELECT INSERT(`C1`,5,1,'コ') FROM `T1`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T1`;
+SELECT INSERT(`C1`,1,2,' ') FROM `T1`;
+SELECT INSERT(`C1`,1,3,' ') FROM `T1`;
+SELECT INSERT(`C1`,1,4,' ') FROM `T1`;
+SELECT INSERT(`C1`,1,5,' ') FROM `T1`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T1`;
+SELECT INSERT(`C1`,2,2,' ') FROM `T1`;
+SELECT INSERT(`C1`,2,3,' ') FROM `T1`;
+SELECT INSERT(`C1`,2,4,' ') FROM `T1`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T1`;
+SELECT INSERT(`C1`,3,2,' ') FROM `T1`;
+SELECT INSERT(`C1`,3,3,' ') FROM `T1`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T1`;
+SELECT INSERT(`C1`,4,2,' ') FROM `T1`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T1`;
+SELECT INSERT(`C1`,1,1,'か') FROM `T2`;
+SELECT INSERT(`C1`,1,2,'かき') FROM `T2`;
+SELECT INSERT(`C1`,1,3,'かきく') FROM `T2`;
+SELECT INSERT(`C1`,1,4,'かきくけ') FROM `T2`;
+SELECT INSERT(`C1`,1,5,'かきくけこ') FROM `T2`;
+SELECT INSERT(`C1`,2,1,'き') FROM `T2`;
+SELECT INSERT(`C1`,2,2,'きく') FROM `T2`;
+SELECT INSERT(`C1`,2,3,'きくけ') FROM `T2`;
+SELECT INSERT(`C1`,2,4,'きくけこ') FROM `T2`;
+SELECT INSERT(`C1`,3,1,'く') FROM `T2`;
+SELECT INSERT(`C1`,3,2,'くけ') FROM `T2`;
+SELECT INSERT(`C1`,3,3,'くけこ') FROM `T2`;
+SELECT INSERT(`C1`,4,1,'け') FROM `T2`;
+SELECT INSERT(`C1`,4,2,'けこ') FROM `T2`;
+SELECT INSERT(`C1`,5,1,'こ') FROM `T2`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T2`;
+SELECT INSERT(`C1`,1,2,'  ') FROM `T2`;
+SELECT INSERT(`C1`,1,3,'   ') FROM `T2`;
+SELECT INSERT(`C1`,1,4,'    ') FROM `T2`;
+SELECT INSERT(`C1`,1,5,'     ') FROM `T2`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T2`;
+SELECT INSERT(`C1`,2,2,'  ') FROM `T2`;
+SELECT INSERT(`C1`,2,3,'   ') FROM `T2`;
+SELECT INSERT(`C1`,2,4,'    ') FROM `T2`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T2`;
+SELECT INSERT(`C1`,3,2,'  ') FROM `T2`;
+SELECT INSERT(`C1`,3,3,'   ') FROM `T2`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T2`;
+SELECT INSERT(`C1`,4,2,'  ') FROM `T2`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T2`;
+SELECT INSERT(`C1`,1,1,'能') FROM `T3`;
+SELECT INSERT(`C1`,1,2,'能能' ) FROM `T3`;
+SELECT INSERT(`C1`,1,3,'能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,1,4,'能能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,1,5,'能能能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,2,1,'能') FROM `T3`;
+SELECT INSERT(`C1`,2,2,'能能' ) FROM `T3`;
+SELECT INSERT(`C1`,2,3,'能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,2,4,'能能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,3,1,'能') FROM `T3`;
+SELECT INSERT(`C1`,3,2,'能能' ) FROM `T3`;
+SELECT INSERT(`C1`,3,3,'能能能' ) FROM `T3`;
+SELECT INSERT(`C1`,4,1,'能') FROM `T3`;
+SELECT INSERT(`C1`,4,2,'能能' ) FROM `T3`;
+SELECT INSERT(`C1`,5,1,'能') FROM `T3`;
+
+#MyISAM
+SELECT INSERT(`C1`,1,1,'カ') FROM `T4`;
+SELECT INSERT(`C1`,1,2,'カキ') FROM `T4`;
+SELECT INSERT(`C1`,1,3,'カキク') FROM `T4`;
+SELECT INSERT(`C1`,1,4,'カキクケ') FROM `T4`;
+SELECT INSERT(`C1`,1,5,'カキクケコ') FROM `T4`;
+SELECT INSERT(`C1`,2,1,'キ') FROM `T4`;
+SELECT INSERT(`C1`,2,2,'キク') FROM `T4`;
+SELECT INSERT(`C1`,2,3,'キクケ') FROM `T4`;
+SELECT INSERT(`C1`,2,4,'キクケコ') FROM `T4`;
+SELECT INSERT(`C1`,3,1,'ク') FROM `T4`;
+SELECT INSERT(`C1`,3,2,'クケ') FROM `T4`;
+SELECT INSERT(`C1`,3,3,'クケコ') FROM `T4`;
+SELECT INSERT(`C1`,4,1,'ケ') FROM `T4`;
+SELECT INSERT(`C1`,4,2,'ケコ') FROM `T4`;
+SELECT INSERT(`C1`,5,1,'コ') FROM `T4`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T4`;
+SELECT INSERT(`C1`,1,2,' ') FROM `T4`;
+SELECT INSERT(`C1`,1,3,' ') FROM `T4`;
+SELECT INSERT(`C1`,1,4,' ') FROM `T4`;
+SELECT INSERT(`C1`,1,5,' ') FROM `T4`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T4`;
+SELECT INSERT(`C1`,2,2,' ') FROM `T4`;
+SELECT INSERT(`C1`,2,3,' ') FROM `T4`;
+SELECT INSERT(`C1`,2,4,' ') FROM `T4`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T4`;
+SELECT INSERT(`C1`,3,2,' ') FROM `T4`;
+SELECT INSERT(`C1`,3,3,' ') FROM `T4`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T4`;
+SELECT INSERT(`C1`,4,2,' ') FROM `T4`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T4`;
+SELECT INSERT(`C1`,1,1,'か') FROM `T5`;
+SELECT INSERT(`C1`,1,2,'かき') FROM `T5`;
+SELECT INSERT(`C1`,1,3,'かきく') FROM `T5`;
+SELECT INSERT(`C1`,1,4,'かきくけ') FROM `T5`;
+SELECT INSERT(`C1`,1,5,'かきくけこ') FROM `T5`;
+SELECT INSERT(`C1`,2,1,'き') FROM `T5`;
+SELECT INSERT(`C1`,2,2,'きく') FROM `T5`;
+SELECT INSERT(`C1`,2,3,'きくけ') FROM `T5`;
+SELECT INSERT(`C1`,2,4,'きくけこ') FROM `T5`;
+SELECT INSERT(`C1`,3,1,'く') FROM `T5`;
+SELECT INSERT(`C1`,3,2,'くけ') FROM `T5`;
+SELECT INSERT(`C1`,3,3,'くけこ') FROM `T5`;
+SELECT INSERT(`C1`,4,1,'け') FROM `T5`;
+SELECT INSERT(`C1`,4,2,'けこ') FROM `T5`;
+SELECT INSERT(`C1`,5,1,'こ') FROM `T5`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T5`;
+SELECT INSERT(`C1`,1,2,'  ') FROM `T5`;
+SELECT INSERT(`C1`,1,3,'   ') FROM `T5`;
+SELECT INSERT(`C1`,1,4,'    ') FROM `T5`;
+SELECT INSERT(`C1`,1,5,'     ') FROM `T5`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T5`;
+SELECT INSERT(`C1`,2,2,'  ') FROM `T5`;
+SELECT INSERT(`C1`,2,3,'   ') FROM `T5`;
+SELECT INSERT(`C1`,2,4,'    ') FROM `T5`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T5`;
+SELECT INSERT(`C1`,3,2,'  ') FROM `T5`;
+SELECT INSERT(`C1`,3,3,'   ') FROM `T5`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T5`;
+SELECT INSERT(`C1`,4,2,'  ') FROM `T5`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T5`;
+SELECT INSERT(`C1`,1,1,'能') FROM `T6`;
+SELECT INSERT(`C1`,1,2,'能能' ) FROM `T6`;
+SELECT INSERT(`C1`,1,3,'能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,1,4,'能能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,1,5,'能能能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,2,1,'能') FROM `T6`;
+SELECT INSERT(`C1`,2,2,'能能') FROM `T6`;
+SELECT INSERT(`C1`,2,3,'能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,2,4,'能能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,3,1,'能') FROM `T6`;
+SELECT INSERT(`C1`,3,2,'能能' ) FROM `T6`;
+SELECT INSERT(`C1`,3,3,'能能能' ) FROM `T6`;
+SELECT INSERT(`C1`,4,1,'能') FROM `T6`;
+SELECT INSERT(`C1`,4,2,'能能' ) FROM `T6`;
+SELECT INSERT(`C1`,5,1,'能') FROM `T6`;
+
+#MEMORY
+SELECT INSERT(`C1`,1,1,'カ') FROM `T7`;
+SELECT INSERT(`C1`,1,2,'カキ') FROM `T7`;
+SELECT INSERT(`C1`,1,3,'カキク') FROM `T7`;
+SELECT INSERT(`C1`,1,4,'カキクケ') FROM `T7`;
+SELECT INSERT(`C1`,1,5,'カキクケコ') FROM `T7`;
+SELECT INSERT(`C1`,2,1,'キ') FROM `T7`;
+SELECT INSERT(`C1`,2,2,'キク') FROM `T7`;
+SELECT INSERT(`C1`,2,3,'キクケ') FROM `T7`;
+SELECT INSERT(`C1`,2,4,'キクケコ') FROM `T7`;
+SELECT INSERT(`C1`,3,1,'ク') FROM `T7`;
+SELECT INSERT(`C1`,3,2,'クケ') FROM `T7`;
+SELECT INSERT(`C1`,3,3,'クケコ') FROM `T7`;
+SELECT INSERT(`C1`,4,1,'ケ') FROM `T7`;
+SELECT INSERT(`C1`,4,2,'ケコ') FROM `T7`;
+SELECT INSERT(`C1`,5,1,'コ') FROM `T7`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T7`;
+SELECT INSERT(`C1`,1,2,' ') FROM `T7`;
+SELECT INSERT(`C1`,1,3,' ') FROM `T7`;
+SELECT INSERT(`C1`,1,4,' ') FROM `T7`;
+SELECT INSERT(`C1`,1,5,' ') FROM `T7`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T7`;
+SELECT INSERT(`C1`,2,2,' ') FROM `T7`;
+SELECT INSERT(`C1`,2,3,' ') FROM `T7`;
+SELECT INSERT(`C1`,2,4,' ') FROM `T7`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T7`;
+SELECT INSERT(`C1`,3,2,' ') FROM `T7`;
+SELECT INSERT(`C1`,3,3,' ') FROM `T7`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T7`;
+SELECT INSERT(`C1`,4,2,' ') FROM `T7`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T7`;
+SELECT INSERT(`C1`,1,1,'か') FROM `T8`;
+SELECT INSERT(`C1`,1,2,'かき') FROM `T8`;
+SELECT INSERT(`C1`,1,3,'かきく') FROM `T8`;
+SELECT INSERT(`C1`,1,4,'かきくけ') FROM `T8`;
+SELECT INSERT(`C1`,1,5,'かきくけこ') FROM `T8`;
+SELECT INSERT(`C1`,2,1,'き') FROM `T8`;
+SELECT INSERT(`C1`,2,2,'きく') FROM `T8`;
+SELECT INSERT(`C1`,2,3,'きくけ') FROM `T8`;
+SELECT INSERT(`C1`,2,4,'きくけこ') FROM `T8`;
+SELECT INSERT(`C1`,3,1,'く') FROM `T8`;
+SELECT INSERT(`C1`,3,2,'くけ') FROM `T8`;
+SELECT INSERT(`C1`,3,3,'くけこ') FROM `T8`;
+SELECT INSERT(`C1`,4,1,'け') FROM `T8`;
+SELECT INSERT(`C1`,4,2,'けこ') FROM `T8`;
+SELECT INSERT(`C1`,5,1,'こ') FROM `T8`;
+SELECT INSERT(`C1`,1,1,' ') FROM `T8`;
+SELECT INSERT(`C1`,1,2,'  ') FROM `T8`;
+SELECT INSERT(`C1`,1,3,'   ') FROM `T8`;
+SELECT INSERT(`C1`,1,4,'    ') FROM `T8`;
+SELECT INSERT(`C1`,1,5,'     ') FROM `T8`;
+SELECT INSERT(`C1`,2,1,' ') FROM `T8`;
+SELECT INSERT(`C1`,2,2,'  ') FROM `T8`;
+SELECT INSERT(`C1`,2,3,'   ') FROM `T8`;
+SELECT INSERT(`C1`,2,4,'    ') FROM `T8`;
+SELECT INSERT(`C1`,3,1,' ') FROM `T8`;
+SELECT INSERT(`C1`,3,2,'  ') FROM `T8`;
+SELECT INSERT(`C1`,3,3,'   ') FROM `T8`;
+SELECT INSERT(`C1`,4,1,' ') FROM `T8`;
+SELECT INSERT(`C1`,4,2,'  ') FROM `T8`;
+SELECT INSERT(`C1`,5,1,' ') FROM `T8`;
+SELECT INSERT(`C1`,1,1,'能') FROM `T9`;
+SELECT INSERT(`C1`,1,2,'能能' ) FROM `T9`;
+SELECT INSERT(`C1`,1,3,'能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,1,4,'能能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,1,5,'能能能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,2,1,'能') FROM `T9`;
+SELECT INSERT(`C1`,2,2,'能能' ) FROM `T9`;
+SELECT INSERT(`C1`,2,3,'能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,2,4,'能能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,3,1,'能') FROM `T9`;
+SELECT INSERT(`C1`,3,2,'能能' ) FROM `T9`;
+SELECT INSERT(`C1`,3,3,'能能能' ) FROM `T9`;
+SELECT INSERT(`C1`,4,1,'能') FROM `T9`;
+SELECT INSERT(`C1`,4,2,'能能' ) FROM `T9`;
+SELECT INSERT(`C1`,5,1,'能') FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_insert_ucs2.test b/mysql-test/suite/jp/t/jp_insert_ucs2.test
new file mode 100644
index 00000000..0cf29ed3
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_insert_ucs2.test
@@ -0,0 +1,283 @@
+--source include/have_ucs2.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 INSERT() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_insert_ujis.test b/mysql-test/suite/jp/t/jp_insert_ujis.test
new file mode 100644
index 00000000..ba046df7
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_insert_ujis.test
@@ -0,0 +1,283 @@
+--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 INSERT() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+SET collation_connection = ujis_japanese_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」ア`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」イ`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」ウ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」エ`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」オ`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」カ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT INSERT(`」テ」ア`,1,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,4,'叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,5,'叱叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,4,'叱叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,3,'叱叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,2,'叱叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,5,1,'叱') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,4,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,5,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,2,4,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,3,3,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,4,2,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,5,1,' ') FROM `」ヤ」キ`;
+SELECT INSERT(`」テ」ア`,1,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,5,'、ォ、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,4,'、ォ、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,3,'、ォ、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,2,'、ォ、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,5,1,'、ォ') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,4,'。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,5,'。。。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,2,4,'。。。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,3,3,'。。。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,4,2,'。。。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,5,1,'。。') FROM `」ヤ」ク`;
+SELECT INSERT(`」テ」ア`,1,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,4,'床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,1,5,'床。床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,2,4,'床。床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,3,3,'床。床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,4,1,'床。') FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,4,2,'床。床。' ) FROM `」ヤ」ケ`;
+SELECT INSERT(`」テ」ア`,5,1,'床。') FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_insert_utf8.test b/mysql-test/suite/jp/t/jp_insert_utf8.test
new file mode 100644
index 00000000..464f3bca
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_insert_utf8.test
@@ -0,0 +1,281 @@
+--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 INSERT() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 INSERT(`シ」シ疏,1,1,'スカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,2,'スカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,3,'スカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,4,'スカスカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,5,'スカスカスカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,1,'スカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,2,'スカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,3,'スカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,4,'スカスカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,1,'スカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,2,'スカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,3,'スカスカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,4,1,'スカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,4,2,'スカスカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,5,1,'スカ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,1,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,2,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,3,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,4,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,5,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,1,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,2,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,3,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,2,4,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,1,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,2,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,3,3,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,4,1,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,4,2,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,5,1,' ') FROM `シエシ疏;
+SELECT INSERT(`シ」シ疏,1,1,'縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,2,'縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,3,'縺九°縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,4,'縺九°縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,5,'縺九°縺九°縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,1,'縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,2,'縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,3,'縺九°縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,4,'縺九°縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,1,'縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,2,'縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,3,'縺九°縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,4,1,'縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,4,2,'縺九°') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,5,1,'縺') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,1,'縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,2,'縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,3,'縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,4,'縲縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,5,'縲縲縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,1,'縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,2,'縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,3,'縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,2,4,'縲縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,1,'縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,2,'縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,3,3,'縲縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,4,1,'縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,4,2,'縲縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,5,1,'縲') FROM `シエシ蛋;
+SELECT INSERT(`シ」シ疏,1,1,'荳') FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,1,2,'荳ゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,1,3,'荳ゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,1,4,'荳ゆクゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,1,5,'荳ゆクゆクゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,2,1,'荳') FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,2,2,'荳ゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,2,3,'荳ゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,2,4,'荳ゆクゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,3,1,'荳') FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,3,2,'荳ゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,3,3,'荳ゆクゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,4,1,'荳') FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,4,2,'荳ゆク' ) FROM `シエシ伝;
+SELECT INSERT(`シ」シ疏,5,1,'荳') FROM `シエシ伝;
+
+#MyISAM
+SELECT INSERT(`シ」シ疏,1,1,'スカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,2,'スカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,3,'スカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,4,'スカスカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,5,'スカスカスカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,1,'スカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,2,'スカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,3,'スカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,4,'スカスカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,1,'スカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,2,'スカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,3,'スカスカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,4,1,'スカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,4,2,'スカスカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,5,1,'スカ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,1,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,2,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,3,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,4,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,5,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,1,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,2,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,3,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,2,4,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,1,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,2,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,3,3,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,4,1,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,4,2,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,5,1,' ') FROM `シエシ覗;
+SELECT INSERT(`シ」シ疏,1,1,'縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,2,'縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,3,'縺九°縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,4,'縺九°縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,5,'縺九°縺九°縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,1,'縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,2,'縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,3,'縺九°縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,4,'縺九°縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,1,'縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,2,'縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,3,'縺九°縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,4,1,'縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,4,2,'縺九°') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,5,1,'縺') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,1,'縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,2,'縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,3,'縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,4,'縲縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,5,'縲縲縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,1,'縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,2,'縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,3,'縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,2,4,'縲縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,1,'縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,2,'縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,3,3,'縲縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,4,1,'縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,4,2,'縲縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,5,1,'縲') FROM `シエシ描;
+SELECT INSERT(`シ」シ疏,1,1,'荳') FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,1,2,'荳ゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,1,3,'荳ゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,1,4,'荳ゆクゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,1,5,'荳ゆクゆクゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,2,1,'荳') FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,2,2,'荳ゆク') FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,2,3,'荳ゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,2,4,'荳ゆクゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,3,1,'荳') FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,3,2,'荳ゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,3,3,'荳ゆクゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,4,1,'荳') FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,4,2,'荳ゆク' ) FROM `シエシ冒;
+SELECT INSERT(`シ」シ疏,5,1,'荳') FROM `シエシ冒;
+
+#MEMORY
+SELECT INSERT(`シ」シ疏,1,1,'スカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,2,'スカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,3,'スカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,4,'スカスカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,5,'スカスカスカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,1,'スカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,2,'スカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,3,'スカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,4,'スカスカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,1,'スカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,2,'スカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,3,'スカスカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,4,1,'スカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,4,2,'スカスカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,5,1,'スカ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,1,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,2,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,3,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,4,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,5,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,1,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,2,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,3,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,2,4,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,1,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,2,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,3,3,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,4,1,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,4,2,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,5,1,' ') FROM `シエシ輿;
+SELECT INSERT(`シ」シ疏,1,1,'縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,2,'縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,3,'縺九°縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,4,'縺九°縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,5,'縺九°縺九°縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,1,'縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,2,'縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,3,'縺九°縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,4,'縺九°縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,1,'縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,2,'縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,3,'縺九°縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,4,1,'縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,4,2,'縺九°') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,5,1,'縺') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,1,'縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,2,'縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,3,'縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,4,'縲縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,5,'縲縲縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,1,'縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,2,'縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,3,'縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,2,4,'縲縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,1,'縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,2,'縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,3,3,'縲縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,4,1,'縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,4,2,'縲縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,5,1,'縲') FROM `シエシ倭;
+SELECT INSERT(`シ」シ疏,1,1,'荳') FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,1,2,'荳ゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,1,3,'荳ゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,1,4,'荳ゆクゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,1,5,'荳ゆクゆクゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,2,1,'荳') FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,2,2,'荳ゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,2,3,'荳ゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,2,4,'荳ゆクゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,3,1,'荳') FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,3,2,'荳ゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,3,3,'荳ゆクゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,4,1,'荳') FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,4,2,'荳ゆク' ) FROM `シエシ兪;
+SELECT INSERT(`シ」シ疏,5,1,'荳') FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_instr_sjis.test b/mysql-test/suite/jp/t/jp_instr_sjis.test
new file mode 100644
index 00000000..626429f2
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_instr_sjis.test
@@ -0,0 +1,111 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test INSTR() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+#InnoDB
+SELECT INSTR(`C1`,'ア') from `T1`;
+SELECT INSTR(`C1`,'イ') from `T1`;
+SELECT INSTR(`C1`,'ウ') from `T1`;
+SELECT INSTR(`C1`,'エ') from `T1`;
+SELECT INSTR(`C1`,'オ') from `T1`;
+SELECT INSTR(`C1`,'ン') from `T1`;
+SELECT INSTR(`C1`,'あ') from `T2`;
+SELECT INSTR(`C1`,'い') from `T2`;
+SELECT INSTR(`C1`,'う') from `T2`;
+SELECT INSTR(`C1`,'え') from `T2`;
+SELECT INSTR(`C1`,'お') from `T2`;
+SELECT INSTR(`C1`,'ん') from `T2`;
+SELECT INSTR(`C1`,'ソ') from `T3`;
+SELECT INSTR(`C1`,'十') from `T3`;
+SELECT INSTR(`C1`,'表') from `T3`;
+SELECT INSTR(`C1`,'予') from `T3`;
+SELECT INSTR(`C1`,'構') from `T3`;
+SELECT INSTR(`C1`,'噂') from `T3`;
+
+#MyISAM
+SELECT INSTR(`C1`,'ア') from `T4`;
+SELECT INSTR(`C1`,'イ') from `T4`;
+SELECT INSTR(`C1`,'ウ') from `T4`;
+SELECT INSTR(`C1`,'エ') from `T4`;
+SELECT INSTR(`C1`,'オ') from `T4`;
+SELECT INSTR(`C1`,'ン') from `T4`;
+SELECT INSTR(`C1`,'あ') from `T5`;
+SELECT INSTR(`C1`,'い') from `T5`;
+SELECT INSTR(`C1`,'う') from `T5`;
+SELECT INSTR(`C1`,'え') from `T5`;
+SELECT INSTR(`C1`,'お') from `T5`;
+SELECT INSTR(`C1`,'ん') from `T5`;
+SELECT INSTR(`C1`,'ソ') from `T6`;
+SELECT INSTR(`C1`,'十') from `T6`;
+SELECT INSTR(`C1`,'表') from `T6`;
+SELECT INSTR(`C1`,'予') from `T6`;
+SELECT INSTR(`C1`,'構') from `T6`;
+SELECT INSTR(`C1`,'噂') from `T6`;
+
+#MEMORY
+SELECT INSTR(`C1`,'ア') from `T7`;
+SELECT INSTR(`C1`,'イ') from `T7`;
+SELECT INSTR(`C1`,'ウ') from `T7`;
+SELECT INSTR(`C1`,'エ') from `T7`;
+SELECT INSTR(`C1`,'オ') from `T7`;
+SELECT INSTR(`C1`,'ン') from `T7`;
+SELECT INSTR(`C1`,'あ') from `T8`;
+SELECT INSTR(`C1`,'い') from `T8`;
+SELECT INSTR(`C1`,'う') from `T8`;
+SELECT INSTR(`C1`,'え') from `T8`;
+SELECT INSTR(`C1`,'お') from `T8`;
+SELECT INSTR(`C1`,'ん') from `T8`;
+SELECT INSTR(`C1`,'ソ') from `T9`;
+SELECT INSTR(`C1`,'十') from `T9`;
+SELECT INSTR(`C1`,'表') from `T9`;
+SELECT INSTR(`C1`,'予') from `T9`;
+SELECT INSTR(`C1`,'構') from `T9`;
+SELECT INSTR(`C1`,'噂') from `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_instr_ucs2.test b/mysql-test/suite/jp/t/jp_instr_ucs2.test
new file mode 100644
index 00000000..a074e315
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_instr_ucs2.test
@@ -0,0 +1,112 @@
+--source include/have_ucs2.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 INSTR() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 INSTR(`」テ」ア`,'竺') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」ウ`;
+
+#MyISAM
+SELECT INSTR(`」テ」ア`,'竺') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」カ`;
+
+#MEMORY
+SELECT INSTR(`」テ」ア`,'竺') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_instr_ujis.test b/mysql-test/suite/jp/t/jp_instr_ujis.test
new file mode 100644
index 00000000..b2dd2335
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_instr_ujis.test
@@ -0,0 +1,111 @@
+--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 INSTR() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 INSTR(`」テ」ア`,'竺') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」ア`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」イ`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」ウ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」ウ`;
+
+#MyISAM
+SELECT INSTR(`」テ」ア`,'竺') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」エ`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」オ`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」カ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」カ`;
+
+#MEMORY
+SELECT INSTR(`」テ」ア`,'竺') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'軸') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'宍') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'雫') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'七') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'爵') from `」ヤ」キ`;
+SELECT INSTR(`」テ」ア`,'、「') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、、') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ヲ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ィ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、ェ') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'、') from `」ヤ」ク`;
+SELECT INSTR(`」テ」ア`,'常ワ') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常ン') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常゙') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常゚') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'常') from `」ヤ」ケ`;
+SELECT INSTR(`」テ」ア`,'床。') from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_instr_utf8.test b/mysql-test/suite/jp/t/jp_instr_utf8.test
new file mode 100644
index 00000000..27c2cb24
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_instr_utf8.test
@@ -0,0 +1,110 @@
+--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 INSTR() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 INSTR(`シ」シ疏,'スア') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'スイ') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'スウ') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'スエ') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'スオ') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'セ') from `シエシ疏;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'繧') from `シエシ蛋;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ伝;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ伝;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ伝;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ伝;
+SELECT INSTR(`シ」シ疏,'鮴。') from `シエシ伝;
+SELECT INSTR(`シ」シ疏,'荳') from `シエシ伝;
+
+#MyISAM
+SELECT INSTR(`シ」シ疏,'スア') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'スイ') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'スウ') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'スエ') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'スオ') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'セ') from `シエシ覗;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'繧') from `シエシ描;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ冒;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ冒;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ冒;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ冒;
+SELECT INSTR(`シ」シ疏,'鮴。') from `シエシ冒;
+SELECT INSTR(`シ」シ疏,'荳') from `シエシ冒;
+
+#MEMORY
+SELECT INSTR(`シ」シ疏,'スア') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'スイ') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'スウ') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'スエ') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'スオ') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'セ') from `シエシ輿;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'縺') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'繧') from `シエシ倭;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ兪;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ兪;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ兪;
+SELECT INSTR(`シ」シ疏,'鮴') from `シエシ兪;
+SELECT INSTR(`シ」シ疏,'鮴。') from `シエシ兪;
+SELECT INSTR(`シ」シ疏,'荳') from `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_join_sjis.test b/mysql-test/suite/jp/t/jp_join_sjis.test
new file mode 100644
index 00000000..031b6bc8
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_join_sjis.test
@@ -0,0 +1,179 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+DROP TABLE IF EXISTS `T1a`;
+DROP TABLE IF EXISTS `T1b`;
+DROP TABLE IF EXISTS `T2a`;
+DROP TABLE IF EXISTS `T2b`;
+DROP TABLE IF EXISTS `T3a`;
+DROP TABLE IF EXISTS `T3b`;
+DROP TABLE IF EXISTS `T4a`;
+DROP TABLE IF EXISTS `T4b`;
+DROP TABLE IF EXISTS `T5a`;
+DROP TABLE IF EXISTS `T5b`;
+DROP TABLE IF EXISTS `T6a`;
+DROP TABLE IF EXISTS `T6b`;
+DROP TABLE IF EXISTS `T7a`;
+DROP TABLE IF EXISTS `T7b`;
+DROP TABLE IF EXISTS `T8a`;
+DROP TABLE IF EXISTS `T8b`;
+DROP TABLE IF EXISTS `T9a`;
+DROP TABLE IF EXISTS `T9b`;
+--enable_warnings
+
+#
+# Test table JOIN using Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T1b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T4b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T7b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+
+#insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `T1a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T1b` VALUES ('ア');
+INSERT INTO `T2a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T2b` VALUES ('あ');
+INSERT INTO `T3a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T3b` VALUES ('ソ');
+INSERT INTO `T4a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T4b` VALUES ('ア');
+INSERT INTO `T5a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T5b` VALUES ('あ');
+INSERT INTO `T6a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T6b` VALUES ('ソ');
+INSERT INTO `T7a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T7b` VALUES ('ア');
+INSERT INTO `T8a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T8b` VALUES ('あ');
+INSERT INTO `T9a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T9b` VALUES ('ソ');
+
+#Test for innodb
+SELECT * FROM `T1a` JOIN `T1b`;
+SELECT * FROM `T1a` INNER JOIN `T1b`;
+SELECT * FROM `T1a` JOIN `T1b` USING (`C1`);
+SELECT * FROM `T1a` INNER JOIN `T1b` USING (`C1`);
+SELECT * FROM `T1a` CROSS JOIN `T1b`;
+SELECT * FROM `T1a` LEFT JOIN `T1b` USING (`C1`);
+SELECT * FROM `T1a` LEFT JOIN `T1b` ON (`T1a`.`C1` = `T1b`.`C1`);
+SELECT * FROM `T1b` RIGHT JOIN `T1a` USING (`C1`);
+SELECT * FROM `T1b` RIGHT JOIN `T1a` ON (`T1a`.`C1` = `T1b`.`C1`);
+SELECT * FROM `T2a` JOIN `T2b`;
+SELECT * FROM `T2a` INNER JOIN `T2b`;
+SELECT * FROM `T2a` JOIN `T2b` USING (`C1`);
+SELECT * FROM `T2a` INNER JOIN `T2b` USING (`C1`);
+SELECT * FROM `T2a` CROSS JOIN `T2b`;
+SELECT * FROM `T2a` LEFT JOIN `T2b` USING (`C1`);
+SELECT * FROM `T2a` LEFT JOIN `T2b` ON (`T2a`.`C1` = `T2b`.`C1`);
+SELECT * FROM `T2b` RIGHT JOIN `T2a` USING (`C1`);
+SELECT * FROM `T2b` RIGHT JOIN `T2a` ON (`T2a`.`C1` = `T2b`.`C1`);
+SELECT * FROM `T3a` JOIN `T3b`;
+SELECT * FROM `T3a` INNER JOIN `T3b`;
+SELECT * FROM `T3a` JOIN `T3b` USING (`C1`);
+SELECT * FROM `T3a` INNER JOIN `T3b` USING (`C1`);
+SELECT * FROM `T3a` CROSS JOIN `T3b`;
+SELECT * FROM `T3a` LEFT JOIN `T3b` USING (`C1`);
+SELECT * FROM `T3a` LEFT JOIN `T3b` ON (`T3a`.`C1` = `T3b`.`C1`);
+SELECT * FROM `T3b` RIGHT JOIN `T3a` USING (`C1`);
+SELECT * FROM `T3b` RIGHT JOIN `T3a` ON (`T3a`.`C1` = `T3b`.`C1`);
+
+#Test for myisam
+SELECT * FROM `T4a` JOIN `T4b`;
+SELECT * FROM `T4a` INNER JOIN `T4b`;
+SELECT * FROM `T4a` JOIN `T4b` USING (`C1`);
+SELECT * FROM `T4a` INNER JOIN `T4b` USING (`C1`);
+SELECT * FROM `T4a` CROSS JOIN `T4b`;
+SELECT * FROM `T4a` LEFT JOIN `T4b` USING (`C1`);
+SELECT * FROM `T4a` LEFT JOIN `T4b` ON (`T4a`.`C1` = `T4b`.`C1`);
+SELECT * FROM `T4b` RIGHT JOIN `T4a` USING (`C1`);
+SELECT * FROM `T4b` RIGHT JOIN `T4a` ON (`T4a`.`C1` = `T4b`.`C1`);
+SELECT * FROM `T5a` JOIN `T5b`;
+SELECT * FROM `T5a` INNER JOIN `T5b`;
+SELECT * FROM `T5a` JOIN `T5b` USING (`C1`);
+SELECT * FROM `T5a` INNER JOIN `T5b` USING (`C1`);
+SELECT * FROM `T5a` CROSS JOIN `T5b`;
+SELECT * FROM `T5a` LEFT JOIN `T5b` USING (`C1`);
+SELECT * FROM `T5a` LEFT JOIN `T5b` ON (`T5a`.`C1` = `T5b`.`C1`);
+SELECT * FROM `T5b` RIGHT JOIN `T5a` USING (`C1`);
+SELECT * FROM `T5b` RIGHT JOIN `T5a` ON (`T5a`.`C1` = `T5b`.`C1`);
+SELECT * FROM `T6a` JOIN `T6b`;
+SELECT * FROM `T6a` INNER JOIN `T6b`;
+SELECT * FROM `T6a` JOIN `T6b` USING (`C1`);
+SELECT * FROM `T6a` INNER JOIN `T6b` USING (`C1`);
+SELECT * FROM `T6a` CROSS JOIN `T6b`;
+SELECT * FROM `T6a` LEFT JOIN `T6b` USING (`C1`);
+SELECT * FROM `T6a` LEFT JOIN `T6b` ON (`T6a`.`C1` = `T6b`.`C1`);
+SELECT * FROM `T6b` RIGHT JOIN `T6a` USING (`C1`);
+SELECT * FROM `T6b` RIGHT JOIN `T6a` ON (`T6a`.`C1` = `T6b`.`C1`);
+
+#Test for MEMORY
+SELECT * FROM `T7a` JOIN `T7b`;
+SELECT * FROM `T7a` INNER JOIN `T7b`;
+SELECT * FROM `T7a` JOIN `T7b` USING (`C1`);
+SELECT * FROM `T7a` INNER JOIN `T7b` USING (`C1`);
+SELECT * FROM `T7a` CROSS JOIN `T7b`;
+SELECT * FROM `T7a` LEFT JOIN `T7b` USING (`C1`);
+SELECT * FROM `T7a` LEFT JOIN `T7b` ON (`T7a`.`C1` = `T7b`.`C1`);
+SELECT * FROM `T7b` RIGHT JOIN `T7a` USING (`C1`);
+SELECT * FROM `T7b` RIGHT JOIN `T7a` ON (`T7a`.`C1` = `T7b`.`C1`);
+SELECT * FROM `T8a` JOIN `T8b`;
+SELECT * FROM `T8a` INNER JOIN `T8b`;
+SELECT * FROM `T8a` JOIN `T8b` USING (`C1`);
+SELECT * FROM `T8a` INNER JOIN `T8b` USING (`C1`);
+SELECT * FROM `T8a` CROSS JOIN `T8b`;
+SELECT * FROM `T8a` LEFT JOIN `T8b` USING (`C1`);
+SELECT * FROM `T8a` LEFT JOIN `T8b` ON (`T8a`.`C1` = `T8b`.`C1`);
+SELECT * FROM `T8b` RIGHT JOIN `T8a` USING (`C1`);
+SELECT * FROM `T8b` RIGHT JOIN `T8a` ON (`T8a`.`C1` = `T8b`.`C1`);
+SELECT * FROM `T9a` JOIN `T9b`;
+SELECT * FROM `T9a` INNER JOIN `T9b`;
+SELECT * FROM `T9a` JOIN `T9b` USING (`C1`);
+SELECT * FROM `T9a` INNER JOIN `T9b` USING (`C1`);
+SELECT * FROM `T9a` CROSS JOIN `T9b`;
+SELECT * FROM `T9a` LEFT JOIN `T9b` USING (`C1`);
+SELECT * FROM `T9a` LEFT JOIN `T9b` ON (`T9a`.`C1` = `T9b`.`C1`);
+SELECT * FROM `T9b` RIGHT JOIN `T9a` USING (`C1`);
+SELECT * FROM `T9b` RIGHT JOIN `T9a` ON (`T9a`.`C1` = `T9b`.`C1`);
+
+DROP TABLE `T1a`;
+DROP TABLE `T1b`;
+DROP TABLE `T2a`;
+DROP TABLE `T2b`;
+DROP TABLE `T3a`;
+DROP TABLE `T3b`;
+DROP TABLE `T4a`;
+DROP TABLE `T4b`;
+DROP TABLE `T5a`;
+DROP TABLE `T5b`;
+DROP TABLE `T6a`;
+DROP TABLE `T6b`;
+DROP TABLE `T7a`;
+DROP TABLE `T7b`;
+DROP TABLE `T8a`;
+DROP TABLE `T8b`;
+DROP TABLE `T9a`;
+DROP TABLE `T9b`;
diff --git a/mysql-test/suite/jp/t/jp_join_ucs2.test b/mysql-test/suite/jp/t/jp_join_ucs2.test
new file mode 100644
index 00000000..2c3a9c24
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_join_ucs2.test
@@ -0,0 +1,180 @@
+--source include/have_ucs2.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS `」ヤ」アa`;
+DROP TABLE IF EXISTS `」ヤ」アb`;
+DROP TABLE IF EXISTS `」ヤ」イa`;
+DROP TABLE IF EXISTS `」ヤ」イb`;
+DROP TABLE IF EXISTS `」ヤ」ウa`;
+DROP TABLE IF EXISTS `」ヤ」ウb`;
+DROP TABLE IF EXISTS `」ヤ」エa`;
+DROP TABLE IF EXISTS `」ヤ」エb`;
+DROP TABLE IF EXISTS `」ヤ」オa`;
+DROP TABLE IF EXISTS `」ヤ」オb`;
+DROP TABLE IF EXISTS `」ヤ」カa`;
+DROP TABLE IF EXISTS `」ヤ」カb`;
+DROP TABLE IF EXISTS `」ヤ」キa`;
+DROP TABLE IF EXISTS `」ヤ」キb`;
+DROP TABLE IF EXISTS `」ヤ」クa`;
+DROP TABLE IF EXISTS `」ヤ」クb`;
+DROP TABLE IF EXISTS `」ヤ」ケa`;
+DROP TABLE IF EXISTS `」ヤ」ケb`;
+--enable_warnings
+
+#
+# Test table JOIN using Japanese characters
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」アa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」アb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」エb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」オa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」オb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」カa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」カb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MyISAM;
+CREATE TABLE `」ヤ」キa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」キb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」クa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」クb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 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` JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` INNER JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` INNER JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` CROSS JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` LEFT JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` LEFT JOIN `」ヤ」アb` ON (`」ヤ」アa`.`」テ」ア` = `」ヤ」アb`.`」テ」ア`);
+SELECT * FROM `」ヤ」アb` RIGHT JOIN `」ヤ」アa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アb` RIGHT JOIN `」ヤ」アa` ON (`」ヤ」アa`.`」テ」ア` = `」ヤ」アb`.`」テ」ア`);
+SELECT * FROM `」ヤ」イa` JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` INNER JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` INNER JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` CROSS JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` LEFT JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` LEFT JOIN `」ヤ」イb` ON (`」ヤ」イa`.`」テ」ア` = `」ヤ」イb`.`」テ」ア`);
+SELECT * FROM `」ヤ」イb` RIGHT JOIN `」ヤ」イa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イb` RIGHT JOIN `」ヤ」イa` ON (`」ヤ」イa`.`」テ」ア` = `」ヤ」イb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` INNER JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` INNER JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` CROSS JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` LEFT JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` LEFT JOIN `」ヤ」ウb` ON (`」ヤ」ウa`.`」テ」ア` = `」ヤ」ウb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ウb` RIGHT JOIN `」ヤ」ウa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウb` RIGHT JOIN `」ヤ」ウa` ON (`」ヤ」ウa`.`」テ」ア` = `」ヤ」ウb`.`」テ」ア`);
+
+#Test for myisam
+SELECT * FROM `」ヤ」エa` JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` INNER JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` INNER JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` CROSS JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` LEFT JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` LEFT JOIN `」ヤ」エb` ON (`」ヤ」エa`.`」テ」ア` = `」ヤ」エb`.`」テ」ア`);
+SELECT * FROM `」ヤ」エb` RIGHT JOIN `」ヤ」エa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エb` RIGHT JOIN `」ヤ」エa` ON (`」ヤ」エa`.`」テ」ア` = `」ヤ」エb`.`」テ」ア`);
+SELECT * FROM `」ヤ」オa` JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` INNER JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` INNER JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` CROSS JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` LEFT JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` LEFT JOIN `」ヤ」オb` ON (`」ヤ」オa`.`」テ」ア` = `」ヤ」オb`.`」テ」ア`);
+SELECT * FROM `」ヤ」オb` RIGHT JOIN `」ヤ」オa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オb` RIGHT JOIN `」ヤ」オa` ON (`」ヤ」オa`.`」テ」ア` = `」ヤ」オb`.`」テ」ア`);
+SELECT * FROM `」ヤ」カa` JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` INNER JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` INNER JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` CROSS JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` LEFT JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` LEFT JOIN `」ヤ」カb` ON (`」ヤ」カa`.`」テ」ア` = `」ヤ」カb`.`」テ」ア`);
+SELECT * FROM `」ヤ」カb` RIGHT JOIN `」ヤ」カa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カb` RIGHT JOIN `」ヤ」カa` ON (`」ヤ」カa`.`」テ」ア` = `」ヤ」カb`.`」テ」ア`);
+
+#Test for MEMORY
+SELECT * FROM `」ヤ」キa` JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` INNER JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` INNER JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` CROSS JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` LEFT JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` LEFT JOIN `」ヤ」キb` ON (`」ヤ」キa`.`」テ」ア` = `」ヤ」キb`.`」テ」ア`);
+SELECT * FROM `」ヤ」キb` RIGHT JOIN `」ヤ」キa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キb` RIGHT JOIN `」ヤ」キa` ON (`」ヤ」キa`.`」テ」ア` = `」ヤ」キb`.`」テ」ア`);
+SELECT * FROM `」ヤ」クa` JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` INNER JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` INNER JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` CROSS JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` LEFT JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` LEFT JOIN `」ヤ」クb` ON (`」ヤ」クa`.`」テ」ア` = `」ヤ」クb`.`」テ」ア`);
+SELECT * FROM `」ヤ」クb` RIGHT JOIN `」ヤ」クa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クb` RIGHT JOIN `」ヤ」クa` ON (`」ヤ」クa`.`」テ」ア` = `」ヤ」クb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` INNER JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` INNER JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` CROSS JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` LEFT JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` LEFT JOIN `」ヤ」ケb` ON (`」ヤ」ケa`.`」テ」ア` = `」ヤ」ケb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ケb` RIGHT JOIN `」ヤ」ケa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケb` RIGHT JOIN `」ヤ」ケa` ON (`」ヤ」ケ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`;
diff --git a/mysql-test/suite/jp/t/jp_join_ujis.test b/mysql-test/suite/jp/t/jp_join_ujis.test
new file mode 100644
index 00000000..973c4669
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_join_ujis.test
@@ -0,0 +1,179 @@
+--source include/have_ujis.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS `」ヤ」アa`;
+DROP TABLE IF EXISTS `」ヤ」アb`;
+DROP TABLE IF EXISTS `」ヤ」イa`;
+DROP TABLE IF EXISTS `」ヤ」イb`;
+DROP TABLE IF EXISTS `」ヤ」ウa`;
+DROP TABLE IF EXISTS `」ヤ」ウb`;
+DROP TABLE IF EXISTS `」ヤ」エa`;
+DROP TABLE IF EXISTS `」ヤ」エb`;
+DROP TABLE IF EXISTS `」ヤ」オa`;
+DROP TABLE IF EXISTS `」ヤ」オb`;
+DROP TABLE IF EXISTS `」ヤ」カa`;
+DROP TABLE IF EXISTS `」ヤ」カb`;
+DROP TABLE IF EXISTS `」ヤ」キa`;
+DROP TABLE IF EXISTS `」ヤ」キb`;
+DROP TABLE IF EXISTS `」ヤ」クa`;
+DROP TABLE IF EXISTS `」ヤ」クb`;
+DROP TABLE IF EXISTS `」ヤ」ケa`;
+DROP TABLE IF EXISTS `」ヤ」ケb`;
+--enable_warnings
+
+#
+# Test table JOIN using Japanese characters
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」アa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」アb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」エb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = memory;
+CREATE TABLE `」ヤ」キb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = memory;
+CREATE TABLE `」ヤ」クa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = memory;
+CREATE TABLE `」ヤ」クb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = memory;
+CREATE TABLE `」ヤ」ケa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = memory;
+CREATE TABLE `」ヤ」ケb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis 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` JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` INNER JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` INNER JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` CROSS JOIN `」ヤ」アb`;
+SELECT * FROM `」ヤ」アa` LEFT JOIN `」ヤ」アb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アa` LEFT JOIN `」ヤ」アb` ON (`」ヤ」アa`.`」テ」ア` = `」ヤ」アb`.`」テ」ア`);
+SELECT * FROM `」ヤ」アb` RIGHT JOIN `」ヤ」アa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」アb` RIGHT JOIN `」ヤ」アa` ON (`」ヤ」アa`.`」テ」ア` = `」ヤ」アb`.`」テ」ア`);
+SELECT * FROM `」ヤ」イa` JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` INNER JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` INNER JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` CROSS JOIN `」ヤ」イb`;
+SELECT * FROM `」ヤ」イa` LEFT JOIN `」ヤ」イb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イa` LEFT JOIN `」ヤ」イb` ON (`」ヤ」イa`.`」テ」ア` = `」ヤ」イb`.`」テ」ア`);
+SELECT * FROM `」ヤ」イb` RIGHT JOIN `」ヤ」イa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」イb` RIGHT JOIN `」ヤ」イa` ON (`」ヤ」イa`.`」テ」ア` = `」ヤ」イb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` INNER JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` INNER JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` CROSS JOIN `」ヤ」ウb`;
+SELECT * FROM `」ヤ」ウa` LEFT JOIN `」ヤ」ウb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウa` LEFT JOIN `」ヤ」ウb` ON (`」ヤ」ウa`.`」テ」ア` = `」ヤ」ウb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ウb` RIGHT JOIN `」ヤ」ウa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ウb` RIGHT JOIN `」ヤ」ウa` ON (`」ヤ」ウa`.`」テ」ア` = `」ヤ」ウb`.`」テ」ア`);
+
+#Test for myisam
+SELECT * FROM `」ヤ」エa` JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` INNER JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` INNER JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` CROSS JOIN `」ヤ」エb`;
+SELECT * FROM `」ヤ」エa` LEFT JOIN `」ヤ」エb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エa` LEFT JOIN `」ヤ」エb` ON (`」ヤ」エa`.`」テ」ア` = `」ヤ」エb`.`」テ」ア`);
+SELECT * FROM `」ヤ」エb` RIGHT JOIN `」ヤ」エa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」エb` RIGHT JOIN `」ヤ」エa` ON (`」ヤ」エa`.`」テ」ア` = `」ヤ」エb`.`」テ」ア`);
+SELECT * FROM `」ヤ」オa` JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` INNER JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` INNER JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` CROSS JOIN `」ヤ」オb`;
+SELECT * FROM `」ヤ」オa` LEFT JOIN `」ヤ」オb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オa` LEFT JOIN `」ヤ」オb` ON (`」ヤ」オa`.`」テ」ア` = `」ヤ」オb`.`」テ」ア`);
+SELECT * FROM `」ヤ」オb` RIGHT JOIN `」ヤ」オa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」オb` RIGHT JOIN `」ヤ」オa` ON (`」ヤ」オa`.`」テ」ア` = `」ヤ」オb`.`」テ」ア`);
+SELECT * FROM `」ヤ」カa` JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` INNER JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` INNER JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` CROSS JOIN `」ヤ」カb`;
+SELECT * FROM `」ヤ」カa` LEFT JOIN `」ヤ」カb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カa` LEFT JOIN `」ヤ」カb` ON (`」ヤ」カa`.`」テ」ア` = `」ヤ」カb`.`」テ」ア`);
+SELECT * FROM `」ヤ」カb` RIGHT JOIN `」ヤ」カa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」カb` RIGHT JOIN `」ヤ」カa` ON (`」ヤ」カa`.`」テ」ア` = `」ヤ」カb`.`」テ」ア`);
+
+#Test for MEMORY
+SELECT * FROM `」ヤ」キa` JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` INNER JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` INNER JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` CROSS JOIN `」ヤ」キb`;
+SELECT * FROM `」ヤ」キa` LEFT JOIN `」ヤ」キb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キa` LEFT JOIN `」ヤ」キb` ON (`」ヤ」キa`.`」テ」ア` = `」ヤ」キb`.`」テ」ア`);
+SELECT * FROM `」ヤ」キb` RIGHT JOIN `」ヤ」キa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」キb` RIGHT JOIN `」ヤ」キa` ON (`」ヤ」キa`.`」テ」ア` = `」ヤ」キb`.`」テ」ア`);
+SELECT * FROM `」ヤ」クa` JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` INNER JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` INNER JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` CROSS JOIN `」ヤ」クb`;
+SELECT * FROM `」ヤ」クa` LEFT JOIN `」ヤ」クb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クa` LEFT JOIN `」ヤ」クb` ON (`」ヤ」クa`.`」テ」ア` = `」ヤ」クb`.`」テ」ア`);
+SELECT * FROM `」ヤ」クb` RIGHT JOIN `」ヤ」クa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」クb` RIGHT JOIN `」ヤ」クa` ON (`」ヤ」クa`.`」テ」ア` = `」ヤ」クb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` INNER JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` INNER JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` CROSS JOIN `」ヤ」ケb`;
+SELECT * FROM `」ヤ」ケa` LEFT JOIN `」ヤ」ケb` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケa` LEFT JOIN `」ヤ」ケb` ON (`」ヤ」ケa`.`」テ」ア` = `」ヤ」ケb`.`」テ」ア`);
+SELECT * FROM `」ヤ」ケb` RIGHT JOIN `」ヤ」ケa` USING (`」テ」ア`);
+SELECT * FROM `」ヤ」ケb` RIGHT JOIN `」ヤ」ケa` ON (`」ヤ」ケ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`;
diff --git a/mysql-test/suite/jp/t/jp_join_utf8.test b/mysql-test/suite/jp/t/jp_join_utf8.test
new file mode 100644
index 00000000..d4e25691
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_join_utf8.test
@@ -0,0 +1,178 @@
+--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 `シエシ病`;
+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 table JOIN using Japanese characters in utf8
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疎` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ礎` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ誕` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ鍛` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ殿` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ澱` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = InnoDB;
+CREATE TABLE `シエシ蚤` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ巴` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ病` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ秒` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ紡` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ肪` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MyISAM;
+CREATE TABLE `シエシ預` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ傭` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ和` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ話` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兮` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ冀` (`シ」シ疏 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 `シエシ疎` 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 ('鮴');
+
+#Test for InnoDB
+SELECT * FROM `シエシ疎` JOIN `シエシ礎`;
+SELECT * FROM `シエシ疎` INNER JOIN `シエシ礎`;
+SELECT * FROM `シエシ疎` JOIN `シエシ礎` USING (`シ」シ疏);
+SELECT * FROM `シエシ疎` INNER JOIN `シエシ礎` USING (`シ」シ疏);
+SELECT * FROM `シエシ疎` CROSS JOIN `シエシ礎`;
+SELECT * FROM `シエシ疎` LEFT JOIN `シエシ礎` USING (`シ」シ疏);
+SELECT * FROM `シエシ疎` LEFT JOIN `シエシ礎` ON (`シエシ疎`.`シ」シ疏 = `シエシ礎`.`シ」シ疏);
+SELECT * FROM `シエシ礎` RIGHT JOIN `シエシ疎` USING (`シ」シ疏);
+SELECT * FROM `シエシ礎` RIGHT JOIN `シエシ疎` ON (`シエシ疎`.`シ」シ疏 = `シエシ礎`.`シ」シ疏);
+SELECT * FROM `シエシ誕` JOIN `シエシ鍛`;
+SELECT * FROM `シエシ誕` INNER JOIN `シエシ鍛`;
+SELECT * FROM `シエシ誕` JOIN `シエシ鍛` USING (`シ」シ疏);
+SELECT * FROM `シエシ誕` INNER JOIN `シエシ鍛` USING (`シ」シ疏);
+SELECT * FROM `シエシ誕` CROSS JOIN `シエシ鍛`;
+SELECT * FROM `シエシ誕` LEFT JOIN `シエシ鍛` USING (`シ」シ疏);
+SELECT * FROM `シエシ誕` LEFT JOIN `シエシ鍛` ON (`シエシ誕`.`シ」シ疏 = `シエシ鍛`.`シ」シ疏);
+SELECT * FROM `シエシ鍛` RIGHT JOIN `シエシ誕` USING (`シ」シ疏);
+SELECT * FROM `シエシ鍛` RIGHT JOIN `シエシ誕` ON (`シエシ誕`.`シ」シ疏 = `シエシ鍛`.`シ」シ疏);
+SELECT * FROM `シエシ殿` JOIN `シエシ澱`;
+SELECT * FROM `シエシ殿` INNER JOIN `シエシ澱`;
+SELECT * FROM `シエシ殿` JOIN `シエシ澱` USING (`シ」シ疏);
+SELECT * FROM `シエシ殿` INNER JOIN `シエシ澱` USING (`シ」シ疏);
+SELECT * FROM `シエシ殿` CROSS JOIN `シエシ澱`;
+SELECT * FROM `シエシ殿` LEFT JOIN `シエシ澱` USING (`シ」シ疏);
+SELECT * FROM `シエシ殿` LEFT JOIN `シエシ澱` ON (`シエシ殿`.`シ」シ疏 = `シエシ澱`.`シ」シ疏);
+SELECT * FROM `シエシ澱` RIGHT JOIN `シエシ殿` USING (`シ」シ疏);
+SELECT * FROM `シエシ澱` RIGHT JOIN `シエシ殿` ON (`シエシ殿`.`シ」シ疏 = `シエシ澱`.`シ」シ疏);
+
+#Test for myisam
+SELECT * FROM `シエシ蚤` JOIN `シエシ巴`;
+SELECT * FROM `シエシ蚤` INNER JOIN `シエシ巴`;
+SELECT * FROM `シエシ蚤` JOIN `シエシ巴` USING (`シ」シ疏);
+SELECT * FROM `シエシ蚤` INNER JOIN `シエシ巴` USING (`シ」シ疏);
+SELECT * FROM `シエシ蚤` CROSS JOIN `シエシ巴`;
+SELECT * FROM `シエシ蚤` LEFT JOIN `シエシ巴` USING (`シ」シ疏);
+SELECT * FROM `シエシ蚤` LEFT JOIN `シエシ巴` ON (`シエシ蚤`.`シ」シ疏 = `シエシ巴`.`シ」シ疏);
+SELECT * FROM `シエシ巴` RIGHT JOIN `シエシ蚤` USING (`シ」シ疏);
+SELECT * FROM `シエシ巴` RIGHT JOIN `シエシ蚤` ON (`シエシ蚤`.`シ」シ疏 = `シエシ巴`.`シ」シ疏);
+SELECT * FROM `シエシ病` JOIN `シエシ秒`;
+SELECT * FROM `シエシ病` INNER JOIN `シエシ秒`;
+SELECT * FROM `シエシ病` JOIN `シエシ秒` USING (`シ」シ疏);
+SELECT * FROM `シエシ病` INNER JOIN `シエシ秒` USING (`シ」シ疏);
+SELECT * FROM `シエシ病` CROSS JOIN `シエシ秒`;
+SELECT * FROM `シエシ病` LEFT JOIN `シエシ秒` USING (`シ」シ疏);
+SELECT * FROM `シエシ病` LEFT JOIN `シエシ秒` ON (`シエシ病`.`シ」シ疏 = `シエシ秒`.`シ」シ疏);
+SELECT * FROM `シエシ秒` RIGHT JOIN `シエシ病` USING (`シ」シ疏);
+SELECT * FROM `シエシ秒` RIGHT JOIN `シエシ病` ON (`シエシ病`.`シ」シ疏 = `シエシ秒`.`シ」シ疏);
+SELECT * FROM `シエシ紡` JOIN `シエシ肪`;
+SELECT * FROM `シエシ紡` INNER JOIN `シエシ肪`;
+SELECT * FROM `シエシ紡` JOIN `シエシ肪` USING (`シ」シ疏);
+SELECT * FROM `シエシ紡` INNER JOIN `シエシ肪` USING (`シ」シ疏);
+SELECT * FROM `シエシ紡` CROSS JOIN `シエシ肪`;
+SELECT * FROM `シエシ紡` LEFT JOIN `シエシ肪` USING (`シ」シ疏);
+SELECT * FROM `シエシ紡` LEFT JOIN `シエシ肪` ON (`シエシ紡`.`シ」シ疏 = `シエシ肪`.`シ」シ疏);
+SELECT * FROM `シエシ肪` RIGHT JOIN `シエシ紡` USING (`シ」シ疏);
+SELECT * FROM `シエシ肪` RIGHT JOIN `シエシ紡` ON (`シエシ紡`.`シ」シ疏 = `シエシ肪`.`シ」シ疏);
+
+#Test for MEMORY
+SELECT * FROM `シエシ預` JOIN `シエシ傭`;
+SELECT * FROM `シエシ預` INNER JOIN `シエシ傭`;
+SELECT * FROM `シエシ預` JOIN `シエシ傭` USING (`シ」シ疏);
+SELECT * FROM `シエシ預` INNER JOIN `シエシ傭` USING (`シ」シ疏);
+SELECT * FROM `シエシ預` CROSS JOIN `シエシ傭`;
+SELECT * FROM `シエシ預` LEFT JOIN `シエシ傭` USING (`シ」シ疏);
+SELECT * FROM `シエシ預` LEFT JOIN `シエシ傭` ON (`シエシ預`.`シ」シ疏 = `シエシ傭`.`シ」シ疏);
+SELECT * FROM `シエシ傭` RIGHT JOIN `シエシ預` USING (`シ」シ疏);
+SELECT * FROM `シエシ傭` RIGHT JOIN `シエシ預` ON (`シエシ預`.`シ」シ疏 = `シエシ傭`.`シ」シ疏);
+SELECT * FROM `シエシ和` JOIN `シエシ話`;
+SELECT * FROM `シエシ和` INNER JOIN `シエシ話`;
+SELECT * FROM `シエシ和` JOIN `シエシ話` USING (`シ」シ疏);
+SELECT * FROM `シエシ和` INNER JOIN `シエシ話` USING (`シ」シ疏);
+SELECT * FROM `シエシ和` CROSS JOIN `シエシ話`;
+SELECT * FROM `シエシ和` LEFT JOIN `シエシ話` USING (`シ」シ疏);
+SELECT * FROM `シエシ和` LEFT JOIN `シエシ話` ON (`シエシ和`.`シ」シ疏 = `シエシ話`.`シ」シ疏);
+SELECT * FROM `シエシ話` RIGHT JOIN `シエシ和` USING (`シ」シ疏);
+SELECT * FROM `シエシ話` RIGHT JOIN `シエシ和` ON (`シエシ和`.`シ」シ疏 = `シエシ話`.`シ」シ疏);
+SELECT * FROM `シエシ兮` JOIN `シエシ冀`;
+SELECT * FROM `シエシ兮` INNER JOIN `シエシ冀`;
+SELECT * FROM `シエシ兮` JOIN `シエシ冀` USING (`シ」シ疏);
+SELECT * FROM `シエシ兮` INNER JOIN `シエシ冀` USING (`シ」シ疏);
+SELECT * FROM `シエシ兮` CROSS JOIN `シエシ冀`;
+SELECT * FROM `シエシ兮` LEFT JOIN `シエシ冀` USING (`シ」シ疏);
+SELECT * FROM `シエシ兮` LEFT JOIN `シエシ冀` ON (`シエシ兮`.`シ」シ疏 = `シエシ冀`.`シ」シ疏);
+SELECT * FROM `シエシ冀` RIGHT JOIN `シエシ兮` USING (`シ」シ疏);
+SELECT * FROM `シエシ冀` RIGHT JOIN `シエシ兮` ON (`シエシ兮`.`シ」シ疏 = `シエシ冀`.`シ」シ疏);
+
+DROP TABLE `シエシ疎`;
+DROP TABLE `シエシ礎`;
+DROP TABLE `シエシ誕`;
+DROP TABLE `シエシ鍛`;
+DROP TABLE `シエシ殿`;
+DROP TABLE `シエシ澱`;
+DROP TABLE `シエシ蚤`;
+DROP TABLE `シエシ巴`;
+DROP TABLE `シエシ病`;
+DROP TABLE `シエシ秒`;
+DROP TABLE `シエシ紡`;
+DROP TABLE `シエシ肪`;
+DROP TABLE `シエシ預`;
+DROP TABLE `シエシ傭`;
+DROP TABLE `シエシ和`;
+DROP TABLE `シエシ話`;
+DROP TABLE `シエシ兮`;
+DROP TABLE `シエシ冀`;
diff --git a/mysql-test/suite/jp/t/jp_left_sjis.test b/mysql-test/suite/jp/t/jp_left_sjis.test
new file mode 100644
index 00000000..0d718ccc
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_left_sjis.test
@@ -0,0 +1,111 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LEFT() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, LEFT(`C1`,0) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T1`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T2`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T3`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T3`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T3`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T3`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T3`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, LEFT(`C1`,0) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T4`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T5`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T6`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T6`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T6`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T6`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T6`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, LEFT(`C1`,0) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T7`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T8`;
+SELECT `C1`, LEFT(`C1`,0) FROM `T9`;
+SELECT `C1`, LEFT(`C1`,1) FROM `T9`;
+SELECT `C1`, LEFT(`C1`,2) FROM `T9`;
+SELECT `C1`, LEFT(`C1`,3) FROM `T9`;
+SELECT `C1`, LEFT(`C1`,4) FROM `T9`;
+SELECT `C1`, LEFT(`C1`,5) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_left_ucs2.test b/mysql-test/suite/jp/t/jp_left_ucs2.test
new file mode 100644
index 00000000..3d55283c
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_left_ucs2.test
@@ -0,0 +1,112 @@
+--source include/have_ucs2.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 LEFT() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_left_ujis.test b/mysql-test/suite/jp/t/jp_left_ujis.test
new file mode 100644
index 00000000..04619fa2
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_left_ujis.test
@@ -0,0 +1,111 @@
+--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 LEFT() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, LEFT(`」テ」ア`,5) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_left_utf8.test b/mysql-test/suite/jp/t/jp_left_utf8.test
new file mode 100644
index 00000000..0f77c170
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_left_utf8.test
@@ -0,0 +1,110 @@
+--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 LEFT() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ疏;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ蛋;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ伝;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ伝;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ伝;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ伝;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ伝;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ覗;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ描;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ冒;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ冒;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ冒;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ冒;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ冒;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ輿;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ倭;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,0) FROM `シエシ兪;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,1) FROM `シエシ兪;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,2) FROM `シエシ兪;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,3) FROM `シエシ兪;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,4) FROM `シエシ兪;
+SELECT `シ」シ疏, LEFT(`シ」シ疏,5) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_length_sjis.test b/mysql-test/suite/jp/t/jp_length_sjis.test
new file mode 100644
index 00000000..acc6be97
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_length_sjis.test
@@ -0,0 +1,66 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LENGTH() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, LENGTH(`C1`) FROM `T1`;
+SELECT `C1`, LENGTH(`C1`) FROM `T2`;
+SELECT `C1`, LENGTH(`C1`) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, LENGTH(`C1`) FROM `T4`;
+SELECT `C1`, LENGTH(`C1`) FROM `T5`;
+SELECT `C1`, LENGTH(`C1`) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, LENGTH(`C1`) FROM `T7`;
+SELECT `C1`, LENGTH(`C1`) FROM `T8`;
+SELECT `C1`, LENGTH(`C1`) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_length_ucs2.test b/mysql-test/suite/jp/t/jp_length_ucs2.test
new file mode 100644
index 00000000..41fd8171
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_length_ucs2.test
@@ -0,0 +1,67 @@
+--source include/have_ucs2.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 LENGTH() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_length_ujis.test b/mysql-test/suite/jp/t/jp_length_ujis.test
new file mode 100644
index 00000000..33a0baa4
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_length_ujis.test
@@ -0,0 +1,66 @@
+--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 LENGTH() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LENGTH(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_length_utf8.test b/mysql-test/suite/jp/t/jp_length_utf8.test
new file mode 100644
index 00000000..ffb5b4fd
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_length_utf8.test
@@ -0,0 +1,65 @@
+--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 LENGTH() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ疏;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ蛋;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ覗;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ描;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ輿;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ倭;
+SELECT `シ」シ疏, LENGTH(`シ」シ疏) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_like_sjis.test b/mysql-test/suite/jp/t/jp_like_sjis.test
new file mode 100644
index 00000000..6cb60928
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_like_sjis.test
@@ -0,0 +1,132 @@
+--character_set sjis
+--source include/have_innodb.inc
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LIKE pattern matching using Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+#Load the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T1`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T2`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T3`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T4`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T5`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T6`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T7`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T8`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T9`;
+
+#InnoDB
+SELECT * FROM `T1` WHERE `C1` LIKE ' %';
+SELECT * FROM `T1` WHERE `C1` LIKE '% %';
+SELECT * FROM `T1` WHERE `C1` LIKE '% ';
+SELECT * FROM `T1` WHERE `C1` LIKE 'タ%';
+SELECT * FROM `T1` WHERE `C1` LIKE '%ラリ%';
+SELECT * FROM `T1` WHERE `C1` LIKE '%ソ';
+SELECT * FROM `T1` WHERE `C1` LIKE 'ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T1` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T1` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T2` WHERE `C1` LIKE ' %';
+SELECT * FROM `T2` WHERE `C1` LIKE '% %';
+SELECT * FROM `T2` WHERE `C1` LIKE '% ';
+SELECT * FROM `T2` WHERE `C1` LIKE 'と%';
+SELECT * FROM `T2` WHERE `C1` LIKE '%あ%';
+SELECT * FROM `T2` WHERE `C1` LIKE '%わ';
+SELECT * FROM `T2` WHERE `C1` LIKE '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T2` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T2` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T3` WHERE `C1` LIKE 'ソ%';
+SELECT * FROM `T3` WHERE `C1` LIKE '%暴%';
+SELECT * FROM `T3` WHERE `C1` LIKE '%杤';
+SELECT * FROM `T3` WHERE `C1` LIKE 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T3` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T3` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+#MyISAM
+SELECT * FROM `T4` WHERE `C1` LIKE ' %';
+SELECT * FROM `T4` WHERE `C1` LIKE '% %';
+SELECT * FROM `T4` WHERE `C1` LIKE '% ';
+SELECT * FROM `T4` WHERE `C1` LIKE 'タ%';
+SELECT * FROM `T4` WHERE `C1` LIKE '%ラリ%';
+SELECT * FROM `T4` WHERE `C1` LIKE '%ソ';
+SELECT * FROM `T4` WHERE `C1` LIKE 'ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T4` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T4` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T5` WHERE `C1` LIKE ' %';
+SELECT * FROM `T5` WHERE `C1` LIKE '% %';
+SELECT * FROM `T5` WHERE `C1` LIKE '% ';
+SELECT * FROM `T5` WHERE `C1` LIKE 'と%';
+SELECT * FROM `T5` WHERE `C1` LIKE '%あ%';
+SELECT * FROM `T5` WHERE `C1` LIKE '%わ';
+SELECT * FROM `T5` WHERE `C1` LIKE '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T5` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T5` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T6` WHERE `C1` LIKE 'ソ%';
+SELECT * FROM `T6` WHERE `C1` LIKE '%暴%';
+SELECT * FROM `T6` WHERE `C1` LIKE '%杤';
+SELECT * FROM `T6` WHERE `C1` LIKE 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T6` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T6` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+#MEMORY
+SELECT * FROM `T7` WHERE `C1` LIKE ' %';
+SELECT * FROM `T7` WHERE `C1` LIKE '% %';
+SELECT * FROM `T7` WHERE `C1` LIKE '% ';
+SELECT * FROM `T7` WHERE `C1` LIKE 'タ%';
+SELECT * FROM `T7` WHERE `C1` LIKE '%ラリ%';
+SELECT * FROM `T7` WHERE `C1` LIKE '%ソ';
+SELECT * FROM `T7` WHERE `C1` LIKE 'ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T7` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ%';
+SELECT * FROM `T7` WHERE `C1` LIKE '%ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T8` WHERE `C1` LIKE ' %';
+SELECT * FROM `T8` WHERE `C1` LIKE '% %';
+SELECT * FROM `T8` WHERE `C1` LIKE '% ';
+SELECT * FROM `T8` WHERE `C1` LIKE 'と%';
+SELECT * FROM `T8` WHERE `C1` LIKE '%あ%';
+SELECT * FROM `T8` WHERE `C1` LIKE '%わ';
+SELECT * FROM `T8` WHERE `C1` LIKE '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T8` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ%';
+SELECT * FROM `T8` WHERE `C1` LIKE '%・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T9` WHERE `C1` LIKE 'ソ%';
+SELECT * FROM `T9` WHERE `C1` LIKE '%暴%';
+SELECT * FROM `T9` WHERE `C1` LIKE '%杤';
+SELECT * FROM `T9` WHERE `C1` LIKE 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T9` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤%';
+SELECT * FROM `T9` WHERE `C1` LIKE '%ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_like_ucs2.test b/mysql-test/suite/jp/t/jp_like_ucs2.test
new file mode 100644
index 00000000..1fd7d559
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_like_ucs2.test
@@ -0,0 +1,209 @@
+--source include/have_ucs2.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 LIKE pattern matching using Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+#Insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `」ヤ」ア` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」イ` VALUES
+ ('。。。。。「。」。、。・。ヲ。ァ。ィ。ゥ。ェ。ォ。ャ。ュ。ョ。ッ。ー。ア。イ。ウ')
+,('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('、ネ、ノ、ハ、ヒ、フ、ヘ、ホ、マ、ミ、ム、メ、モ、ヤ、ユ、ヨ、ラ、リ、ル、レ、ロ')
+,('、ワ、ン、゙、゚、爨皃筅网荀螟讀遉隍鬢熙、、、、')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ウ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」エ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」オ` VALUES
+ ('。。。。。「。」。、。・。ヲ。ァ。ィ。ゥ。ェ。ォ。ャ。ュ。ョ。ッ。ー。ア。イ。ウ')
+,('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('、ネ、ノ、ハ、ヒ、フ、ヘ、ホ、マ、ミ、ム、メ、モ、ヤ、ユ、ヨ、ラ、リ、ル、レ、ロ')
+,('、ワ、ン、゙、゚、爨皃筅网荀螟讀遉隍鬢熙、、、、')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」カ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」キ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」ク` VALUES
+ ('。。。。。「。」。、。・。ヲ。ァ。ィ。ゥ。ェ。ォ。ャ。ュ。ョ。ッ。ー。ア。イ。ウ')
+,('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('、ネ、ノ、ハ、ヒ、フ、ヘ、ホ、マ、ミ、ム、メ、モ、ヤ、ユ、ヨ、ラ、リ、ル、レ、ロ')
+,('、ワ、ン、゙、゚、爨皃筅网荀螟讀遉隍鬢熙、、、、')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ケ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+#INNODB
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MyISAM
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MEMORY
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_like_ujis.test b/mysql-test/suite/jp/t/jp_like_ujis.test
new file mode 100644
index 00000000..dccb49d0
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_like_ujis.test
@@ -0,0 +1,134 @@
+--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 LIKE pattern matching using Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis 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_ujis.dat' INTO TABLE `」ヤ」ア`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」イ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ウ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」エ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」オ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」カ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」キ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」ク`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ケ`;
+
+#InnoDB
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MyISAM
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MEMORY
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE ' %';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '% %';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '% ';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '実%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%邪借%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%質';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質%';
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` LIKE '%鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '。。%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。。%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。。';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '、ネ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%、「%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%、';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ%';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` LIKE '%。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '常エ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常サ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常ヌ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ%';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` LIKE '%常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_like_utf8.test b/mysql-test/suite/jp/t/jp_like_utf8.test
new file mode 100644
index 00000000..4332922f
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_like_utf8.test
@@ -0,0 +1,133 @@
+--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 LIKE pattern matching using Japanese characters 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 * FROM `シエシ疏 WHERE `シ」シ疏 LIKE ' %';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '% %';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '% ';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE 'セ%';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '%セ暦セ%';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '%スソ';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ疏 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '縲%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%縲%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%縲';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '縺ィ%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%縺%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%繧';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '鮠ォ%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '%鮠コ%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '%鮨';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+#MyISAM
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE ' %';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '% %';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '% ';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE 'セ%';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '%セ暦セ%';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '%スソ';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '縲%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%縲%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%縲';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '縺ィ%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%縺%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%繧';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '鮠ォ%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '%鮠コ%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '%鮨';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+#MEMORY
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE ' %';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '% %';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '% ';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE 'セ%';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '%セ暦セ%';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '%スソ';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ%';
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 LIKE '%スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '縲%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%縲%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%縲';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '縺ィ%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%縺%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%繧';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%%';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 LIKE '%繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '鮠ォ%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '%鮠コ%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '%鮨';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 LIKE '%鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_locate_sjis.test b/mysql-test/suite/jp/t/jp_locate_sjis.test
new file mode 100644
index 00000000..e7a21e0e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_locate_sjis.test
@@ -0,0 +1,112 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LOCATE() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+#InnoDB
+SELECT LOCATE('ア',`C1`) from `T1`;
+SELECT LOCATE('イ',`C1`) from `T1`;
+SELECT LOCATE('ウ',`C1`) from `T1`;
+SELECT LOCATE('エ',`C1`) from `T1`;
+SELECT LOCATE('オ',`C1`) from `T1`;
+SELECT LOCATE('ン',`C1`) from `T1`;
+SELECT LOCATE('あ',`C1`) from `T2`;
+SELECT LOCATE('い',`C1`) from `T2`;
+SELECT LOCATE('う',`C1`) from `T2`;
+SELECT LOCATE('え',`C1`) from `T2`;
+SELECT LOCATE('お',`C1`) from `T2`;
+SELECT LOCATE('ん',`C1`) from `T2`;
+SELECT LOCATE('ソ',`C1`) from `T3`;
+SELECT LOCATE('十',`C1`) from `T3`;
+SELECT LOCATE('表',`C1`) from `T3`;
+SELECT LOCATE('予',`C1`) from `T3`;
+SELECT LOCATE('構',`C1`) from `T3`;
+SELECT LOCATE('噂',`C1`) from `T3`;
+
+#MyISAM
+SELECT LOCATE('ア',`C1`) from `T4`;
+SELECT LOCATE('イ',`C1`) from `T4`;
+SELECT LOCATE('ウ',`C1`) from `T4`;
+SELECT LOCATE('エ',`C1`) from `T4`;
+SELECT LOCATE('オ',`C1`) from `T4`;
+SELECT LOCATE('ン',`C1`) from `T4`;
+SELECT LOCATE('あ',`C1`) from `T5`;
+SELECT LOCATE('い',`C1`) from `T5`;
+SELECT LOCATE('う',`C1`) from `T5`;
+SELECT LOCATE('え',`C1`) from `T5`;
+SELECT LOCATE('お',`C1`) from `T5`;
+SELECT LOCATE('ん',`C1`) from `T5`;
+SELECT LOCATE('ソ',`C1`) from `T6`;
+SELECT LOCATE('十',`C1`) from `T6`;
+SELECT LOCATE('表',`C1`) from `T6`;
+SELECT LOCATE('予',`C1`) from `T6`;
+SELECT LOCATE('構',`C1`) from `T6`;
+SELECT LOCATE('噂',`C1`) from `T6`;
+
+
+#MEMORY
+SELECT LOCATE('ア',`C1`) from `T7`;
+SELECT LOCATE('イ',`C1`) from `T7`;
+SELECT LOCATE('ウ',`C1`) from `T7`;
+SELECT LOCATE('エ',`C1`) from `T7`;
+SELECT LOCATE('オ',`C1`) from `T7`;
+SELECT LOCATE('ン',`C1`) from `T7`;
+SELECT LOCATE('あ',`C1`) from `T8`;
+SELECT LOCATE('い',`C1`) from `T8`;
+SELECT LOCATE('う',`C1`) from `T8`;
+SELECT LOCATE('え',`C1`) from `T8`;
+SELECT LOCATE('お',`C1`) from `T8`;
+SELECT LOCATE('ん',`C1`) from `T8`;
+SELECT LOCATE('ソ',`C1`) from `T9`;
+SELECT LOCATE('十',`C1`) from `T9`;
+SELECT LOCATE('表',`C1`) from `T9`;
+SELECT LOCATE('予',`C1`) from `T9`;
+SELECT LOCATE('構',`C1`) from `T9`;
+SELECT LOCATE('噂',`C1`) from `T9`;
+
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_locate_ucs2.test b/mysql-test/suite/jp/t/jp_locate_ucs2.test
new file mode 100644
index 00000000..02b95a20
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_locate_ucs2.test
@@ -0,0 +1,114 @@
+--source include/have_ucs2.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 LOCATE() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 LOCATE('竺',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT LOCATE('竺',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」カ`;
+
+
+#MEMORY
+SELECT LOCATE('竺',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」ケ`;
+
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_locate_ujis.test b/mysql-test/suite/jp/t/jp_locate_ujis.test
new file mode 100644
index 00000000..21e3fa1d
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_locate_ujis.test
@@ -0,0 +1,113 @@
+--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 LOCATE() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 LOCATE('竺',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」ア`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」イ`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」ウ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT LOCATE('竺',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」エ`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」オ`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」カ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」カ`;
+
+
+#MEMORY
+SELECT LOCATE('竺',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('軸',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('宍',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('雫',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('七',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('爵',`」テ」ア`) from `」ヤ」キ`;
+SELECT LOCATE('、「',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、、',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ヲ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ィ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、ェ',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('、',`」テ」ア`) from `」ヤ」ク`;
+SELECT LOCATE('常ワ',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常ン',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常゙',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常゚',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('常',`」テ」ア`) from `」ヤ」ケ`;
+SELECT LOCATE('床。',`」テ」ア`) from `」ヤ」ケ`;
+
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_locate_utf8.test b/mysql-test/suite/jp/t/jp_locate_utf8.test
new file mode 100644
index 00000000..6e965eaf
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_locate_utf8.test
@@ -0,0 +1,112 @@
+--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 LOCATE() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 LOCATE('スア',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('スイ',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('スウ',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('スエ',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('スオ',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('セ',`シ」シ疏) from `シエシ疏;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('繧',`シ」シ疏) from `シエシ蛋;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ伝;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ伝;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ伝;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ伝;
+SELECT LOCATE('鮴。',`シ」シ疏) from `シエシ伝;
+SELECT LOCATE('荳',`シ」シ疏) from `シエシ伝;
+
+#MyISAM
+SELECT LOCATE('スア',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('スイ',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('スウ',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('スエ',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('スオ',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('セ',`シ」シ疏) from `シエシ覗;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('繧',`シ」シ疏) from `シエシ描;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ冒;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ冒;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ冒;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ冒;
+SELECT LOCATE('鮴。',`シ」シ疏) from `シエシ冒;
+SELECT LOCATE('荳',`シ」シ疏) from `シエシ冒;
+
+
+#MEMORY
+SELECT LOCATE('スア',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('スイ',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('スウ',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('スエ',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('スオ',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('セ',`シ」シ疏) from `シエシ輿;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('縺',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('繧',`シ」シ疏) from `シエシ倭;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ兪;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ兪;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ兪;
+SELECT LOCATE('鮴',`シ」シ疏) from `シエシ兪;
+SELECT LOCATE('鮴。',`シ」シ疏) from `シエシ兪;
+SELECT LOCATE('荳',`シ」シ疏) from `シエシ兪;
+
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_lpad_sjis.test b/mysql-test/suite/jp/t/jp_lpad_sjis.test
new file mode 100644
index 00000000..1516acc1
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_lpad_sjis.test
@@ -0,0 +1,66 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LPAD() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, LPAD(`C1`,5,'。') FROM `T1`;
+SELECT `C1`, LPAD(`C1`,5,'X') FROM `T2`;
+SELECT `C1`, LPAD(`C1`,5,'暴') FROM `T3`;
+
+#MyISAM
+SELECT `C1`, LPAD(`C1`,5,'。') FROM `T4`;
+SELECT `C1`, LPAD(`C1`,5,'X') FROM `T5`;
+SELECT `C1`, LPAD(`C1`,5,'暴' ) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, LPAD(`C1`,5,'。') FROM `T7`;
+SELECT `C1`, LPAD(`C1`,5,'X') FROM `T8`;
+SELECT `C1`, LPAD(`C1`,5,'暴' ) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_lpad_ucs2.test b/mysql-test/suite/jp/t/jp_lpad_ucs2.test
new file mode 100644
index 00000000..3f8e9fd9
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_lpad_ucs2.test
@@ -0,0 +1,67 @@
+--source include/have_ucs2.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 LPAD() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_lpad_ujis.test b/mysql-test/suite/jp/t/jp_lpad_ujis.test
new file mode 100644
index 00000000..9d4ef185
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_lpad_ujis.test
@@ -0,0 +1,66 @@
+--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 LPAD() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」ア`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」イ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」エ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」オ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'治') FROM `」ヤ」キ`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」ク`;
+SELECT `」テ」ア`, LPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_lpad_utf8.test b/mysql-test/suite/jp/t/jp_lpad_utf8.test
new file mode 100644
index 00000000..b629751d
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_lpad_utf8.test
@@ -0,0 +1,65 @@
+--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 LPAD() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, LPAD(`シ」シ疏,5,'ス。') FROM `シエシ疏;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'シク') FROM `シエシ蛋;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'荳') FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'ス。') FROM `シエシ覗;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'シク') FROM `シエシ描;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'荳' ) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'ス。') FROM `シエシ輿;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'シク') FROM `シエシ倭;
+SELECT `シ」シ疏, LPAD(`シ」シ疏,5,'荳' ) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_ltrim_sjis.test b/mysql-test/suite/jp/t/jp_ltrim_sjis.test
new file mode 100644
index 00000000..4a02fcdc
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ltrim_sjis.test
@@ -0,0 +1,129 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test LTRIM() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T1` VALUES (' アイウエオ');
+INSERT INTO `T1` VALUES (' アイウエオ');
+INSERT INTO `T1` VALUES (' アイウエオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T1` VALUES (' アイウエオ');
+INSERT INTO `T1` VALUES ('  アイウエオ');
+INSERT INTO `T1` VALUES ('   アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T2` VALUES (' あいうえお');
+INSERT INTO `T2` VALUES (' あいうえお');
+INSERT INTO `T2` VALUES (' あいうえお');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T2` VALUES (' あいうえお');
+INSERT INTO `T2` VALUES ('  あいうえお');
+INSERT INTO `T2` VALUES ('   あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T3` VALUES (' ソ十表予構');
+INSERT INTO `T3` VALUES (' ソ十表予構');
+INSERT INTO `T3` VALUES (' ソ十表予構');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T3` VALUES (' ソ十表予構');
+INSERT INTO `T3` VALUES ('  ソ十表予構');
+INSERT INTO `T3` VALUES ('   ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T4` VALUES (' アイウエオ');
+INSERT INTO `T4` VALUES (' アイウエオ');
+INSERT INTO `T4` VALUES (' アイウエオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T4` VALUES (' アイウエオ');
+INSERT INTO `T4` VALUES ('  アイウエオ');
+INSERT INTO `T4` VALUES ('   アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T5` VALUES (' あいうえお');
+INSERT INTO `T5` VALUES (' あいうえお');
+INSERT INTO `T5` VALUES (' あいうえお');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T5` VALUES (' あいうえお');
+INSERT INTO `T5` VALUES ('  あいうえお');
+INSERT INTO `T5` VALUES ('   あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T6` VALUES (' ソ十表予構');
+INSERT INTO `T6` VALUES (' ソ十表予構');
+INSERT INTO `T6` VALUES (' ソ十表予構');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T6` VALUES (' ソ十表予構');
+INSERT INTO `T6` VALUES ('  ソ十表予構');
+INSERT INTO `T6` VALUES ('   ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T7` VALUES (' アイウエオ');
+INSERT INTO `T7` VALUES (' アイウエオ');
+INSERT INTO `T7` VALUES (' アイウエオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T7` VALUES (' アイウエオ');
+INSERT INTO `T7` VALUES ('  アイウエオ');
+INSERT INTO `T7` VALUES ('   アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T8` VALUES (' あいうえお');
+INSERT INTO `T8` VALUES (' あいうえお');
+INSERT INTO `T8` VALUES (' あいうえお');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T8` VALUES (' あいうえお');
+INSERT INTO `T8` VALUES ('  あいうえお');
+INSERT INTO `T8` VALUES ('   あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+INSERT INTO `T9` VALUES (' ソ十表予構');
+INSERT INTO `T9` VALUES (' ソ十表予構');
+INSERT INTO `T9` VALUES (' ソ十表予構');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T9` VALUES (' ソ十表予構');
+INSERT INTO `T9` VALUES ('  ソ十表予構');
+INSERT INTO `T9` VALUES ('   ソ十表予構');
+
+#InnoDB
+SELECT LTRIM(`C1`) from `T1`;
+SELECT LTRIM(`C1`) from `T2`;
+SELECT LTRIM(`C1`) from `T3`;
+
+#MyISAM
+SELECT LTRIM(`C1`) from `T4`;
+SELECT LTRIM(`C1`) from `T5`;
+SELECT LTRIM(`C1`) from `T6`;
+
+#MEMORY
+SELECT LTRIM(`C1`) from `T7`;
+SELECT LTRIM(`C1`) from `T8`;
+SELECT LTRIM(`C1`) from `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_ltrim_ucs2.test b/mysql-test/suite/jp/t/jp_ltrim_ucs2.test
new file mode 100644
index 00000000..65ea8d01
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ltrim_ucs2.test
@@ -0,0 +1,130 @@
+--source include/have_ucs2.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 LTRIM() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ア` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」イ` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ウ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」エ` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」オ` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」カ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」キ` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ク` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ケ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+
+#InnoDB
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ア`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」イ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT LTRIM(`」テ」ア`) from `」ヤ」エ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」オ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」カ`;
+
+#MEMORY
+SELECT LTRIM(`」テ」ア`) from `」ヤ」キ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ク`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_ltrim_ujis.test b/mysql-test/suite/jp/t/jp_ltrim_ujis.test
new file mode 100644
index 00000000..9c5487a3
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ltrim_ujis.test
@@ -0,0 +1,129 @@
+--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 LTRIM() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ア` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」イ` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ウ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」エ` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」オ` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」カ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES (' 竺軸宍雫七');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」キ` VALUES ('。。竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('。。。。。。竺軸宍雫七');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES (' 、「、、、ヲ、ィ、ェ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ク` VALUES ('。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('。。。。。。、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES (' 常ワ常ン常゙常゚常');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ケ` VALUES ('。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('。。。。常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('。。。。。。常ワ常ン常゙常゚常');
+
+#InnoDB
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ア`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」イ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT LTRIM(`」テ」ア`) from `」ヤ」エ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」オ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」カ`;
+
+#MEMORY
+SELECT LTRIM(`」テ」ア`) from `」ヤ」キ`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ク`;
+SELECT LTRIM(`」テ」ア`) from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_ltrim_utf8.test b/mysql-test/suite/jp/t/jp_ltrim_utf8.test
new file mode 100644
index 00000000..3fcd5cbd
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ltrim_utf8.test
@@ -0,0 +1,128 @@
+--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 LTRIM() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES (' スアスイスウスエスオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ疏 VALUES ('縲スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES ('縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES ('縲縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES (' 縺ゅ>縺縺医♀');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ蛋 VALUES ('縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES ('縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES ('縲縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ伝 VALUES ('縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES ('縲縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES ('縲縲縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES (' スアスイスウスエスオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ覗 VALUES ('縲スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES ('縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES ('縲縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES (' 縺ゅ>縺縺医♀');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ描 VALUES ('縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES ('縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES ('縲縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ冒 VALUES ('縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES ('縲縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES ('縲縲縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES (' スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES (' スアスイスウスエスオ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ輿 VALUES ('縲スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES ('縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES ('縲縲縲スアスイスウスエスオ');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES (' 縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES (' 縺ゅ>縺縺医♀');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ倭 VALUES ('縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES ('縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES ('縲縲縲縺ゅ>縺縺医♀');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES (' 鮴秘セ夜セ鈴セ樣セ。');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ兪 VALUES ('縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES ('縲縲鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES ('縲縲縲鮴秘セ夜セ鈴セ樣セ。');
+
+#InnoDB
+SELECT LTRIM(`シ」シ疏) from `シエシ疏;
+SELECT LTRIM(`シ」シ疏) from `シエシ蛋;
+SELECT LTRIM(`シ」シ疏) from `シエシ伝;
+
+#MyISAM
+SELECT LTRIM(`シ」シ疏) from `シエシ覗;
+SELECT LTRIM(`シ」シ疏) from `シエシ描;
+SELECT LTRIM(`シ」シ疏) from `シエシ冒;
+
+#MEMORY
+SELECT LTRIM(`シ」シ疏) from `シエシ輿;
+SELECT LTRIM(`シ」シ疏) from `シエシ倭;
+SELECT LTRIM(`シ」シ疏) from `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_ps_sjis.test b/mysql-test/suite/jp/t/jp_ps_sjis.test
new file mode 100644
index 00000000..123ac904
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ps_sjis.test
@@ -0,0 +1,348 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+
+--character_set sjis
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+
+#
+# Test Prepares Statement with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+### Test InnoDB ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = InnoDB;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = InnoDB;
+CREATE TABLE t3(
+ `ア` char(1),
+ `あ` char(1),
+ `表` char(1)
+)DEFAULT CHARSET = sjis ENGINE = InnoDB;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = sjis ENGINE = InnoDB;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('アあ表');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('ア'),('あ'),('表');
+
+# Japanese parameter for column name
+# the parameter for stmt is not interpreted as column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,10,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,10,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = 'ア';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = 'あ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+# Test jisx0212 ##
+SET @arg = '表';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+### Test MyISAM ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = MyISAM;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = MyISAM;
+CREATE TABLE t3(
+ `ア` char(1),
+ `あ` char(1),
+ `表` char(1)
+)DEFAULT CHARSET = sjis ENGINE = MyISAM;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = sjis ENGINE = MyISAM;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('アあ表');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('ア'),('あ'),('表' );
+
+# Japanese parameter for column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,10,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,10,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = 'ア';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = 'あ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0212 ##
+SET @arg = '表';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+### Test MEMORY ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = MEMORY;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = sjis ENGINE = MEMORY;
+CREATE TABLE t3(
+ `ア` char(1),
+ `あ` char(1),
+ `表` char(1)
+)DEFAULT CHARSET = sjis ENGINE = MEMORY;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = sjis ENGINE =MEMORY;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('アあ表');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('ア'),('あ'),('表' );
+
+# Japanese parameter for column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,10,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,10,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = 'ア';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = 'あ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0212 ##
+SET @arg = '表';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/mysql-test/suite/jp/t/jp_ps_ujis.test b/mysql-test/suite/jp/t/jp_ps_ujis.test
new file mode 100644
index 00000000..78b86ad5
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_ps_ujis.test
@@ -0,0 +1,347 @@
+--source include/have_ujis.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+
+#
+# Test Prepares Statement with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+### Test InnoDB ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = InnoDB;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = InnoDB;
+CREATE TABLE t3(
+ `竺` char(1),
+ `、「` char(1),
+ `常ワ` char(1)
+)DEFAULT CHARSET = ujis ENGINE = InnoDB;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = ujis ENGINE = InnoDB;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('竺、「常ワ');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('竺'),('、「'),('常ワ');
+
+# Japanese parameter for column name
+# the parameter for stmt is not interpreted as column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,9,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,9,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = '竺';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = '、「';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+# Test jisx0212 ##
+SET @arg = '常ワ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+### Test MyISAM ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = MyISAM;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = MyISAM;
+CREATE TABLE t3(
+ `竺` char(1),
+ `、「` char(1),
+ `常ワ` char(1)
+)DEFAULT CHARSET = ujis ENGINE = MyISAM;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = ujis ENGINE = MyISAM;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('竺、「常ワ');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('竺'),('、「'),('常ワ' );
+
+# Japanese parameter for column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,9,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,9,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = '竺';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = '、「';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0212 ##
+SET @arg = '常ワ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+### Test MEMORY ###
+CREATE TABLE t1(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = MEMORY;
+CREATE TABLE t2(c1 char(3)) DEFAULT CHARSET = ujis ENGINE = MEMORY;
+CREATE TABLE t3(
+ `竺` char(1),
+ `、「` char(1),
+ `常ワ` char(1)
+)DEFAULT CHARSET = ujis ENGINE = MEMORY;
+CREATE TABLE t4(c1 char(1)) DEFAULT CHARSET = ujis ENGINE =MEMORY;
+
+INSERT INTO t1 VALUES ('xxx');
+INSERT INTO t2 VALUES ('竺、「常ワ');
+INSERT INTO t3 VALUES ('x','x','x'),('x','x','x'),('y','y','y'),('y','y','y'),('z','z','z'),('z','z','z');
+INSERT INTO t4 VALUES ('竺'),('、「'),('常ワ' );
+
+# Japanese parameter for column name
+PREPARE stmt1 FROM 'SELECT ? FROM t3';
+PREPARE stmt2 FROM 'SELECT * FROM t3 ORDER BY ?';
+PREPARE stmt3 FROM 'SELECT COUNT(*) FROM t3 GROUP BY ?';
+# Japanese parameter for function argument
+PREPARE stmt4 FROM 'SELECT CHAR_LENGTH(?)';
+PREPARE stmt5 FROM 'SELECT CHARSET(?)';
+PREPARE stmt6 FROM 'SELECT INSERT(c1,1,1,?) FROM t1';
+PREPARE stmt7 FROM 'SELECT INSTR(c1,?) FROM t2';
+PREPARE stmt8 FROM 'SELECT LOCATE(?,c1) FROM t2';
+PREPARE stmt9 FROM 'SELECT LPAD(c1,9,?) FROM t1';
+PREPARE stmt10 FROM 'SELECT REPLACE(c1,?,\'x\') FROM t2';
+PREPARE stmt11 FROM 'SELECT REPLACE(c1,\'x\',?) FROM t1';
+PREPARE stmt12 FROM 'SELECT RPAD(c1,9,?) FROM t1';
+# Japanese parameter for UPDATE
+PREPARE stmt13 FROM 'UPDATE t4 SET c1=\'x\' WHERE c1=?';
+PREPARE stmt14 FROM 'UPDATE t4 SET c1=? WHERE c1=\'x\'';
+
+## Test jisx0201 ##
+SET @arg = '竺';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0208 ##
+SET @arg = '、「';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+## Test jisx0212 ##
+SET @arg = '常ワ';
+EXECUTE stmt1 USING @arg;
+EXECUTE stmt2 USING @arg;
+EXECUTE stmt3 USING @arg;
+EXECUTE stmt4 USING @arg;
+EXECUTE stmt5 USING @arg;
+EXECUTE stmt6 USING @arg;
+EXECUTE stmt7 USING @arg;
+EXECUTE stmt8 USING @arg;
+EXECUTE stmt9 USING @arg;
+EXECUTE stmt10 USING @arg;
+EXECUTE stmt11 USING @arg;
+EXECUTE stmt12 USING @arg;
+EXECUTE stmt13 USING @arg;
+SELECT * FROM t4;
+EXECUTE stmt14 USING @arg;
+SELECT * FROM t4;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DEALLOCATE PREPARE stmt3;
+DEALLOCATE PREPARE stmt4;
+DEALLOCATE PREPARE stmt5;
+DEALLOCATE PREPARE stmt6;
+DEALLOCATE PREPARE stmt7;
+DEALLOCATE PREPARE stmt8;
+DEALLOCATE PREPARE stmt9;
+DEALLOCATE PREPARE stmt10;
+DEALLOCATE PREPARE stmt11;
+DEALLOCATE PREPARE stmt12;
+DEALLOCATE PREPARE stmt13;
+DEALLOCATE PREPARE stmt14;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
diff --git a/mysql-test/suite/jp/t/jp_replace_sjis.test b/mysql-test/suite/jp/t/jp_replace_sjis.test
new file mode 100644
index 00000000..ab29b875
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_replace_sjis.test
@@ -0,0 +1,102 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test REPLACE() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+#InnoDB
+SELECT REPLACE(`C1`,'ア','アア') FROM `T1`;
+SELECT REPLACE(`C1`,'イ','イイ') FROM `T1`;
+SELECT REPLACE(`C1`,'ウ','ウウ') FROM `T1`;
+SELECT REPLACE(`C1`,'エ','エエ') FROM `T1`;
+SELECT REPLACE(`C1`,'オ','オオ') FROM `T1`;
+SELECT REPLACE(`C1`,'あ','ああ') FROM `T2`;
+SELECT REPLACE(`C1`,'い','いい') FROM `T2`;
+SELECT REPLACE(`C1`,'う','うう') FROM `T2`;
+SELECT REPLACE(`C1`,'え','ええ') FROM `T2`;
+SELECT REPLACE(`C1`,'お','おお') FROM `T2`;
+SELECT REPLACE(`C1`,'ソ','ソソ') FROM `T3`;
+SELECT REPLACE(`C1`,'十','十十') FROM `T3`;
+SELECT REPLACE(`C1`,'表','表表') FROM `T3`;
+SELECT REPLACE(`C1`,'予','予予') FROM `T3`;
+SELECT REPLACE(`C1`,'構','構構') FROM `T3`;
+
+#MyISAM
+SELECT REPLACE(`C1`,'ア','アア') FROM `T4`;
+SELECT REPLACE(`C1`,'イ','イイ') FROM `T4`;
+SELECT REPLACE(`C1`,'ウ','ウウ') FROM `T4`;
+SELECT REPLACE(`C1`,'エ','エエ') FROM `T4`;
+SELECT REPLACE(`C1`,'オ','オオ') FROM `T4`;
+SELECT REPLACE(`C1`,'あ','ああ') FROM `T5`;
+SELECT REPLACE(`C1`,'い','いい') FROM `T5`;
+SELECT REPLACE(`C1`,'う','うう') FROM `T5`;
+SELECT REPLACE(`C1`,'え','ええ') FROM `T5`;
+SELECT REPLACE(`C1`,'お','おお') FROM `T5`;
+SELECT REPLACE(`C1`,'ソ','ソソ') FROM `T6`;
+SELECT REPLACE(`C1`,'十','十十') FROM `T6`;
+SELECT REPLACE(`C1`,'表','表表') FROM `T6`;
+SELECT REPLACE(`C1`,'予','予予') FROM `T6`;
+SELECT REPLACE(`C1`,'構','構構') FROM `T6`;
+
+#MEMORY
+SELECT REPLACE(`C1`,'ア','アア') FROM `T7`;
+SELECT REPLACE(`C1`,'イ','イイ') FROM `T7`;
+SELECT REPLACE(`C1`,'ウ','ウウ') FROM `T7`;
+SELECT REPLACE(`C1`,'エ','エエ') FROM `T7`;
+SELECT REPLACE(`C1`,'オ','オオ') FROM `T7`;
+SELECT REPLACE(`C1`,'あ','ああ') FROM `T8`;
+SELECT REPLACE(`C1`,'い','いい') FROM `T8`;
+SELECT REPLACE(`C1`,'う','うう') FROM `T8`;
+SELECT REPLACE(`C1`,'え','ええ') FROM `T8`;
+SELECT REPLACE(`C1`,'お','おお') FROM `T8`;
+SELECT REPLACE(`C1`,'ソ','ソソ') FROM `T9`;
+SELECT REPLACE(`C1`,'十','十十') FROM `T9`;
+SELECT REPLACE(`C1`,'表','表表') FROM `T9`;
+SELECT REPLACE(`C1`,'予','予予') FROM `T9`;
+SELECT REPLACE(`C1`,'構','構構') FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_replace_ucs2.test b/mysql-test/suite/jp/t/jp_replace_ucs2.test
new file mode 100644
index 00000000..fc9982ca
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_replace_ucs2.test
@@ -0,0 +1,103 @@
+--source include/have_ucs2.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 REPLACE() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_replace_ujis.test b/mysql-test/suite/jp/t/jp_replace_ujis.test
new file mode 100644
index 00000000..a830dcd9
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_replace_ujis.test
@@ -0,0 +1,102 @@
+--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 REPLACE() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」ア`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」イ`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」ウ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」エ`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」オ`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」カ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT REPLACE(`」テ」ア`,'竺','竺竺') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'軸','軸軸') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'宍','宍宍') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'雫','雫雫') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'七','七七') FROM `」ヤ」キ`;
+SELECT REPLACE(`」テ」ア`,'、「','、「、「') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、、','、、、、') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ヲ','、ヲ、ヲ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ィ','、ィ、ィ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'、ェ','、ェ、ェ') FROM `」ヤ」ク`;
+SELECT REPLACE(`」テ」ア`,'常ワ','常ワ常ワ') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常ン','常ン常ン') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常゙','常゙常゙') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常゚','常゚常゚') FROM `」ヤ」ケ`;
+SELECT REPLACE(`」テ」ア`,'常','常熄') FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_replace_utf8.test b/mysql-test/suite/jp/t/jp_replace_utf8.test
new file mode 100644
index 00000000..fe5d3167
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_replace_utf8.test
@@ -0,0 +1,101 @@
+--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 REPLACE() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 REPLACE(`シ」シ疏,'スア','スアスア') FROM `シエシ疏;
+SELECT REPLACE(`シ」シ疏,'スイ','スイスイ') FROM `シエシ疏;
+SELECT REPLACE(`シ」シ疏,'スウ','スウスウ') FROM `シエシ疏;
+SELECT REPLACE(`シ」シ疏,'スエ','スエスエ') FROM `シエシ疏;
+SELECT REPLACE(`シ」シ疏,'スオ','スオスオ') FROM `シエシ疏;
+SELECT REPLACE(`シ」シ疏,'縺','縺ゅ≠') FROM `シエシ蛋;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ蛋;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ蛋;
+SELECT REPLACE(`シ」シ疏,'縺','縺医∴') FROM `シエシ蛋;
+SELECT REPLACE(`シ」シ疏,'縺','縺翫♀') FROM `シエシ蛋;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴秘セ') FROM `シエシ伝;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴夜セ') FROM `シエシ伝;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴鈴セ') FROM `シエシ伝;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴樣セ') FROM `シエシ伝;
+SELECT REPLACE(`シ」シ疏,'鮴。','鮴。鮴。') FROM `シエシ伝;
+
+#MyISAM
+SELECT REPLACE(`シ」シ疏,'スア','スアスア') FROM `シエシ覗;
+SELECT REPLACE(`シ」シ疏,'スイ','スイスイ') FROM `シエシ覗;
+SELECT REPLACE(`シ」シ疏,'スウ','スウスウ') FROM `シエシ覗;
+SELECT REPLACE(`シ」シ疏,'スエ','スエスエ') FROM `シエシ覗;
+SELECT REPLACE(`シ」シ疏,'スオ','スオスオ') FROM `シエシ覗;
+SELECT REPLACE(`シ」シ疏,'縺','縺ゅ≠') FROM `シエシ描;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ描;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ描;
+SELECT REPLACE(`シ」シ疏,'縺','縺医∴') FROM `シエシ描;
+SELECT REPLACE(`シ」シ疏,'縺','縺翫♀') FROM `シエシ描;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴秘セ') FROM `シエシ冒;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴夜セ') FROM `シエシ冒;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴鈴セ') FROM `シエシ冒;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴樣セ') FROM `シエシ冒;
+SELECT REPLACE(`シ」シ疏,'鮴。','鮴。鮴。') FROM `シエシ冒;
+
+#MEMORY
+SELECT REPLACE(`シ」シ疏,'スア','スアスア') FROM `シエシ輿;
+SELECT REPLACE(`シ」シ疏,'スイ','スイスイ') FROM `シエシ輿;
+SELECT REPLACE(`シ」シ疏,'スウ','スウスウ') FROM `シエシ輿;
+SELECT REPLACE(`シ」シ疏,'スエ','スエスエ') FROM `シエシ輿;
+SELECT REPLACE(`シ」シ疏,'スオ','スオスオ') FROM `シエシ輿;
+SELECT REPLACE(`シ」シ疏,'縺','縺ゅ≠') FROM `シエシ倭;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ倭;
+SELECT REPLACE(`シ」シ疏,'縺','縺縺') FROM `シエシ倭;
+SELECT REPLACE(`シ」シ疏,'縺','縺医∴') FROM `シエシ倭;
+SELECT REPLACE(`シ」シ疏,'縺','縺翫♀') FROM `シエシ倭;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴秘セ') FROM `シエシ兪;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴夜セ') FROM `シエシ兪;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴鈴セ') FROM `シエシ兪;
+SELECT REPLACE(`シ」シ疏,'鮴','鮴樣セ') FROM `シエシ兪;
+SELECT REPLACE(`シ」シ疏,'鮴。','鮴。鮴。') FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_reverse_sjis.test b/mysql-test/suite/jp/t/jp_reverse_sjis.test
new file mode 100644
index 00000000..2acc9bf9
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_reverse_sjis.test
@@ -0,0 +1,66 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test REVERSE() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+#InnoDB
+SELECT REVERSE(`C1`) FROM `T1`;
+SELECT REVERSE(`C1`) FROM `T2`;
+SELECT REVERSE(`C1`) FROM `T3`;
+
+#MyISAM
+SELECT REVERSE(`C1`) FROM `T4`;
+SELECT REVERSE(`C1`) FROM `T5`;
+SELECT REVERSE(`C1`) FROM `T6`;
+
+#MEMORY
+SELECT REVERSE(`C1`) FROM `T7`;
+SELECT REVERSE(`C1`) FROM `T8`;
+SELECT REVERSE(`C1`) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_reverse_ucs2.test b/mysql-test/suite/jp/t/jp_reverse_ucs2.test
new file mode 100644
index 00000000..3bf2d492
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_reverse_ucs2.test
@@ -0,0 +1,67 @@
+--source include/have_ucs2.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 REVERSE() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 REVERSE(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_reverse_ujis.test b/mysql-test/suite/jp/t/jp_reverse_ujis.test
new file mode 100644
index 00000000..0e6ea60e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_reverse_ujis.test
@@ -0,0 +1,66 @@
+--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 REVERSE() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 REVERSE(`」テ」ア`) FROM `」ヤ」ア`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」イ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」エ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」オ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」キ`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ク`;
+SELECT REVERSE(`」テ」ア`) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_reverse_utf8.test b/mysql-test/suite/jp/t/jp_reverse_utf8.test
new file mode 100644
index 00000000..ce49b571
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_reverse_utf8.test
@@ -0,0 +1,65 @@
+--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 REVERSE() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 REVERSE(`シ」シ疏) FROM `シエシ疏;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ蛋;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ伝;
+
+#MyISAM
+SELECT REVERSE(`シ」シ疏) FROM `シエシ覗;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ描;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ冒;
+
+#MEMORY
+SELECT REVERSE(`シ」シ疏) FROM `シエシ輿;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ倭;
+SELECT REVERSE(`シ」シ疏) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_right_sjis.test b/mysql-test/suite/jp/t/jp_right_sjis.test
new file mode 100644
index 00000000..8cde4233
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_right_sjis.test
@@ -0,0 +1,111 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test RIGHT() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, RIGHT(`C1`,0) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T1`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T2`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T3`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T3`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T3`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T3`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T3`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, RIGHT(`C1`,0) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T4`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T5`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T6`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T6`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T6`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T6`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T6`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, RIGHT(`C1`,0) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T7`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T8`;
+SELECT `C1`, RIGHT(`C1`,0) FROM `T9`;
+SELECT `C1`, RIGHT(`C1`,1) FROM `T9`;
+SELECT `C1`, RIGHT(`C1`,2) FROM `T9`;
+SELECT `C1`, RIGHT(`C1`,3) FROM `T9`;
+SELECT `C1`, RIGHT(`C1`,4) FROM `T9`;
+SELECT `C1`, RIGHT(`C1`,5) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_right_ucs2.test b/mysql-test/suite/jp/t/jp_right_ucs2.test
new file mode 100644
index 00000000..bb914787
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_right_ucs2.test
@@ -0,0 +1,112 @@
+--source include/have_ucs2.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 RIGHT() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_right_ujis.test b/mysql-test/suite/jp/t/jp_right_ujis.test
new file mode 100644
index 00000000..bb478af7
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_right_ujis.test
@@ -0,0 +1,111 @@
+--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 RIGHT() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, RIGHT(`」テ」ア`,5) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_right_utf8.test b/mysql-test/suite/jp/t/jp_right_utf8.test
new file mode 100644
index 00000000..0f435fb5
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_right_utf8.test
@@ -0,0 +1,110 @@
+--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 RIGHT() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ疏;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ蛋;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ伝;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ伝;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ伝;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ伝;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ伝;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ覗;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ描;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ冒;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ冒;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ冒;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ冒;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ冒;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ輿;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ倭;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,0) FROM `シエシ兪;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,1) FROM `シエシ兪;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,2) FROM `シエシ兪;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,3) FROM `シエシ兪;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,4) FROM `シエシ兪;
+SELECT `シ」シ疏, RIGHT(`シ」シ疏,5) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_rpad_sjis.test b/mysql-test/suite/jp/t/jp_rpad_sjis.test
new file mode 100644
index 00000000..16715ee7
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rpad_sjis.test
@@ -0,0 +1,66 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test RPAD() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, RPAD(`C1`,5,'。') FROM `T1`;
+SELECT `C1`, RPAD(`C1`,5,'X') FROM `T2`;
+SELECT `C1`, RPAD(`C1`,5,'暴') FROM `T3`;
+
+#MyISAM
+SELECT `C1`, RPAD(`C1`,5,'。') FROM `T4`;
+SELECT `C1`, RPAD(`C1`,5,'X') FROM `T5`;
+SELECT `C1`, RPAD(`C1`,5,'暴' ) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, RPAD(`C1`,5,'。') FROM `T7`;
+SELECT `C1`, RPAD(`C1`,5,'X') FROM `T8`;
+SELECT `C1`, RPAD(`C1`,5,'暴' ) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_rpad_ucs2.test b/mysql-test/suite/jp/t/jp_rpad_ucs2.test
new file mode 100644
index 00000000..9f39c20e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rpad_ucs2.test
@@ -0,0 +1,67 @@
+--source include/have_ucs2.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 RPAD() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_rpad_ujis.test b/mysql-test/suite/jp/t/jp_rpad_ujis.test
new file mode 100644
index 00000000..ad150f36
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rpad_ujis.test
@@ -0,0 +1,66 @@
+--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 RPAD() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」ア`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」イ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「') FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」エ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」オ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'治') FROM `」ヤ」キ`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'」リ') FROM `」ヤ」ク`;
+SELECT `」テ」ア`, RPAD(`」テ」ア`,5,'床「' ) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_rpad_utf8.test b/mysql-test/suite/jp/t/jp_rpad_utf8.test
new file mode 100644
index 00000000..329165f1
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rpad_utf8.test
@@ -0,0 +1,66 @@
+--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 RPAD() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, RPAD(`シ」シ疏,5,'ス。') FROM `シエシ疏;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'シク') FROM `シエシ蛋;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'荳') FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'ス。') FROM `シエシ覗;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'シク') FROM `シエシ描;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'荳' ) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'ス。') FROM `シエシ輿;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'シク') FROM `シエシ倭;
+SELECT `シ」シ疏, RPAD(`シ」シ疏,5,'荳' ) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_rtrim_sjis.test b/mysql-test/suite/jp/t/jp_rtrim_sjis.test
new file mode 100644
index 00000000..6a9ded05
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rtrim_sjis.test
@@ -0,0 +1,129 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test RTRIM() function with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(8), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T1` VALUES ('アイウエオ ');
+INSERT INTO `T1` VALUES ('アイウエオ ');
+INSERT INTO `T1` VALUES ('アイウエオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T1` VALUES ('アイウエオ ');
+INSERT INTO `T1` VALUES ('アイウエオ  ');
+INSERT INTO `T1` VALUES ('アイウエオ   ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T2` VALUES ('あいうえお ');
+INSERT INTO `T2` VALUES ('あいうえお ');
+INSERT INTO `T2` VALUES ('あいうえお ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T2` VALUES ('あいうえお ');
+INSERT INTO `T2` VALUES ('あいうえお  ');
+INSERT INTO `T2` VALUES ('あいうえお   ');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T3` VALUES ('ソ十表予構 ');
+INSERT INTO `T3` VALUES ('ソ十表予構 ');
+INSERT INTO `T3` VALUES ('ソ十表予構 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T3` VALUES ('ソ十表予構 ');
+INSERT INTO `T3` VALUES ('ソ十表予構  ');
+INSERT INTO `T3` VALUES ('ソ十表予構   ');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T4` VALUES ('アイウエオ ');
+INSERT INTO `T4` VALUES ('アイウエオ ');
+INSERT INTO `T4` VALUES ('アイウエオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T4` VALUES ('アイウエオ ');
+INSERT INTO `T4` VALUES ('アイウエオ  ');
+INSERT INTO `T4` VALUES ('アイウエオ   ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T5` VALUES ('あいうえお ');
+INSERT INTO `T5` VALUES ('あいうえお ');
+INSERT INTO `T5` VALUES ('あいうえお ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T5` VALUES ('あいうえお ');
+INSERT INTO `T5` VALUES ('あいうえお  ');
+INSERT INTO `T5` VALUES ('あいうえお   ');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T6` VALUES ('ソ十表予構 ');
+INSERT INTO `T6` VALUES ('ソ十表予構 ');
+INSERT INTO `T6` VALUES ('ソ十表予構 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T6` VALUES ('ソ十表予構 ');
+INSERT INTO `T6` VALUES ('ソ十表予構  ');
+INSERT INTO `T6` VALUES ('ソ十表予構   ');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T7` VALUES ('アイウエオ ');
+INSERT INTO `T7` VALUES ('アイウエオ ');
+INSERT INTO `T7` VALUES ('アイウエオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T7` VALUES ('アイウエオ ');
+INSERT INTO `T7` VALUES ('アイウエオ  ');
+INSERT INTO `T7` VALUES ('アイウエオ   ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T8` VALUES ('あいうえお ');
+INSERT INTO `T8` VALUES ('あいうえお ');
+INSERT INTO `T8` VALUES ('あいうえお ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T8` VALUES ('あいうえお ');
+INSERT INTO `T8` VALUES ('あいうえお  ');
+INSERT INTO `T8` VALUES ('あいうえお   ');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+INSERT INTO `T9` VALUES ('ソ十表予構 ');
+INSERT INTO `T9` VALUES ('ソ十表予構 ');
+INSERT INTO `T9` VALUES ('ソ十表予構 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `T9` VALUES ('ソ十表予構 ');
+INSERT INTO `T9` VALUES ('ソ十表予構  ');
+INSERT INTO `T9` VALUES ('ソ十表予構   ');
+
+#InnoDB
+SELECT RTRIM(`C1`) from `T1`;
+SELECT RTRIM(`C1`) from `T2`;
+SELECT RTRIM(`C1`) from `T3`;
+
+#MyISAM
+SELECT RTRIM(`C1`) from `T4`;
+SELECT RTRIM(`C1`) from `T5`;
+SELECT RTRIM(`C1`) from `T6`;
+
+#MEMORY
+SELECT RTRIM(`C1`) from `T7`;
+SELECT RTRIM(`C1`) from `T8`;
+SELECT RTRIM(`C1`) from `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_rtrim_ucs2.test b/mysql-test/suite/jp/t/jp_rtrim_ucs2.test
new file mode 100644
index 00000000..84cd1ce4
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rtrim_ucs2.test
@@ -0,0 +1,130 @@
+--source include/have_ucs2.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 RTRIM() function with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+
+#InnoDB
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ア`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」イ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT RTRIM(`」テ」ア`) from `」ヤ」エ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」オ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」カ`;
+
+#MEMORY
+SELECT RTRIM(`」テ」ア`) from `」ヤ」キ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ク`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_rtrim_ujis.test b/mysql-test/suite/jp/t/jp_rtrim_ujis.test
new file mode 100644
index 00000000..5037419d
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rtrim_ujis.test
@@ -0,0 +1,129 @@
+--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 RTRIM() function with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(8), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」ア` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」イ` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」ウ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」エ` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」オ` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」カ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。。。');
+INSERT INTO `」ヤ」キ` VALUES ('竺軸宍雫七。。。。。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。。。');
+INSERT INTO `」ヤ」ク` VALUES ('、「、、、ヲ、ィ、ェ。。。。。。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。。。');
+INSERT INTO `」ヤ」ケ` VALUES ('常ワ常ン常゙常゚常爍。。。。。');
+
+#InnoDB
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ア`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」イ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ウ`;
+
+#MyISAM
+SELECT RTRIM(`」テ」ア`) from `」ヤ」エ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」オ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」カ`;
+
+#MEMORY
+SELECT RTRIM(`」テ」ア`) from `」ヤ」キ`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ク`;
+SELECT RTRIM(`」テ」ア`) from `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_rtrim_utf8.test b/mysql-test/suite/jp/t/jp_rtrim_utf8.test
new file mode 100644
index 00000000..f1161d16
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_rtrim_utf8.test
@@ -0,0 +1,128 @@
+--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 RTRIM() function with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(8), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ縲');
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ縲縲');
+INSERT INTO `シエシ疏 VALUES ('スアスイスウスエスオ縲縲縲');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀縲');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀縲縲');
+INSERT INTO `シエシ蛋 VALUES ('縺ゅ>縺縺医♀縲縲縲');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲');
+INSERT INTO `シエシ伝 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲縲');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ縲');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ縲縲');
+INSERT INTO `シエシ覗 VALUES ('スアスイスウスエスオ縲縲縲');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀縲');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀縲縲');
+INSERT INTO `シエシ描 VALUES ('縺ゅ>縺縺医♀縲縲縲');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲');
+INSERT INTO `シエシ冒 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲縲');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ ');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ縲');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ縲縲');
+INSERT INTO `シエシ輿 VALUES ('スアスイスウスエスオ縲縲縲');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀ ');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀ ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀縲');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀縲縲');
+INSERT INTO `シエシ倭 VALUES ('縺ゅ>縺縺医♀縲縲縲');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。 ');
+# Double byte spaces are not supposed to be trimed
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲');
+INSERT INTO `シエシ兪 VALUES ('鮴秘セ夜セ鈴セ樣セ。縲縲縲');
+
+#InnoDB
+SELECT RTRIM(`シ」シ疏) from `シエシ疏;
+SELECT RTRIM(`シ」シ疏) from `シエシ蛋;
+SELECT RTRIM(`シ」シ疏) from `シエシ伝;
+
+#MyISAM
+SELECT RTRIM(`シ」シ疏) from `シエシ覗;
+SELECT RTRIM(`シ」シ疏) from `シエシ描;
+SELECT RTRIM(`シ」シ疏) from `シエシ冒;
+
+#MEMORY
+SELECT RTRIM(`シ」シ疏) from `シエシ輿;
+SELECT RTRIM(`シ」シ疏) from `シエシ倭;
+SELECT RTRIM(`シ」シ疏) from `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_select_sjis.test b/mysql-test/suite/jp/t/jp_select_sjis.test
new file mode 100644
index 00000000..f96dfadc
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_select_sjis.test
@@ -0,0 +1,69 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test Displaying Japanese charact in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis 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_sjis.dat' INTO TABLE `T1`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T2`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T3`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T4`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T5`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T6`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T7`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T8`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T9`;
+
+#InnoDB
+SELECT * FROM `T1`;
+SELECT * FROM `T2`;
+SELECT * FROM `T3`;
+#MyISAM
+SELECT * FROM `T4`;
+SELECT * FROM `T5`;
+SELECT * FROM `T6`;
+#MEMORY
+SELECT * FROM `T7`;
+SELECT * FROM `T8`;
+SELECT * FROM `T9`;
+
+drop table `T1`;
+drop table `T2`;
+drop table `T3`;
+drop table `T4`;
+drop table `T5`;
+drop table `T6`;
+drop table `T7`;
+drop table `T8`;
+drop table `T9`;
diff --git a/mysql-test/suite/jp/t/jp_select_ucs2.test b/mysql-test/suite/jp/t/jp_select_ucs2.test
new file mode 100644
index 00000000..9acca2d6
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_select_ucs2.test
@@ -0,0 +1,135 @@
+--source include/have_ucs2.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 Displaying Japanese charact in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = heap;
+CREATE TABLE `」ヤ」ク` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = heap;
+CREATE TABLE `」ヤ」ケ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ucs2 engine = heap;
+
+#INSERT the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `」ヤ」ア` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」イ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ウ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」エ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」オ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」カ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」キ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」ク` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ケ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+#InnoDB
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+#MyISAM
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+#Heap
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+drop table `」ヤ」ア`;
+drop table `」ヤ」イ`;
+drop table `」ヤ」ウ`;
+drop table `」ヤ」エ`;
+drop table `」ヤ」オ`;
+drop table `」ヤ」カ`;
+drop table `」ヤ」キ`;
+drop table `」ヤ」ク`;
+drop table `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_select_ujis.test b/mysql-test/suite/jp/t/jp_select_ujis.test
new file mode 100644
index 00000000..0c01e614
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_select_ujis.test
@@ -0,0 +1,69 @@
+--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 Displaying Japanese charact in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (c1 char(20), INDEX(c1)) DEFAULT CHARSET = ujis 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_ujis.dat' INTO TABLE `」ヤ」ア`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」イ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ウ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」エ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」オ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」カ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」キ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」ク`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ケ`;
+
+#InnoDB
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+#MyISAM
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+#MEMORY
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+drop table `」ヤ」ア`;
+drop table `」ヤ」イ`;
+drop table `」ヤ」ウ`;
+drop table `」ヤ」エ`;
+drop table `」ヤ」オ`;
+drop table `」ヤ」カ`;
+drop table `」ヤ」キ`;
+drop table `」ヤ」ク`;
+drop table `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_select_utf8.test b/mysql-test/suite/jp/t/jp_select_utf8.test
new file mode 100644
index 00000000..08157cce
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_select_utf8.test
@@ -0,0 +1,68 @@
+--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 Displaying Japanese charact in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (c1 char(20), INDEX(c1)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (c1 char(20), INDEX(c1)) 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 * FROM `シエシ疏;
+SELECT * FROM `シエシ蛋;
+SELECT * FROM `シエシ伝;
+#MyISAM
+SELECT * FROM `シエシ覗;
+SELECT * FROM `シエシ描;
+SELECT * FROM `シエシ冒;
+#MEMORY
+SELECT * FROM `シエシ輿;
+SELECT * FROM `シエシ倭;
+SELECT * FROM `シエシ兪;
+
+drop table `シエシ疏;
+drop table `シエシ蛋;
+drop table `シエシ伝;
+drop table `シエシ覗;
+drop table `シエシ描;
+drop table `シエシ冒;
+drop table `シエシ輿;
+drop table `シエシ倭;
+drop table `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_subquery_sjis.test b/mysql-test/suite/jp/t/jp_subquery_sjis.test
new file mode 100644
index 00000000..aaaa71b0
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_subquery_sjis.test
@@ -0,0 +1,112 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test subquery using Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T1b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T4b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T7b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9a` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9b` (`C1` char(1) PRIMARY KEY) DEFAULT CHARSET = sjis engine = MEMORY;
+
+#insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `T1a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T1b` VALUES ('ア');
+INSERT INTO `T2a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T2b` VALUES ('あ');
+INSERT INTO `T3a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T3b` VALUES ('ソ');
+INSERT INTO `T4a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T4b` VALUES ('ア');
+INSERT INTO `T5a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T5b` VALUES ('あ');
+INSERT INTO `T6a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T6b` VALUES ('ソ');
+INSERT INTO `T7a` VALUES ('ア'),('カ'),('サ');
+INSERT INTO `T7b` VALUES ('ア');
+INSERT INTO `T8a` VALUES ('あ'),('か'),('さ');
+INSERT INTO `T8b` VALUES ('あ');
+INSERT INTO `T9a` VALUES ('ソ'),('十'),('表');
+INSERT INTO `T9b` VALUES ('ソ');
+
+#Test for innodb
+SELECT `C1` FROM `T1a` WHERE `C1` IN (SELECT `C1` FROM `T1b`);
+SELECT `C1` FROM `T1a` WHERE EXISTS (SELECT `C1` FROM `T1b` WHERE `T1a`.`C1` = `T1b`.`C1`);
+SELECT `C1` FROM `T1a` WHERE NOT EXISTS (SELECT `C1` FROM `T1b` WHERE `T1a`.`C1` = `T1b`.`C1`);
+SELECT `C1` FROM `T2a` WHERE `C1` IN (SELECT `C1` FROM `T2b`);
+SELECT `C1` FROM `T2a` WHERE EXISTS (SELECT `C1` FROM `T2b` WHERE `T2a`.`C1` = `T2b`.`C1`);
+SELECT `C1` FROM `T2a` WHERE NOT EXISTS (SELECT `C1` FROM `T2b` WHERE `T2a`.`C1` = `T2b`.`C1`);
+SELECT `C1` FROM `T3a` WHERE `C1` IN (SELECT `C1` FROM `T3b`);
+SELECT `C1` FROM `T3a` WHERE EXISTS (SELECT `C1` FROM `T3b` WHERE `T3a`.`C1` = `T3b`.`C1`);
+SELECT `C1` FROM `T3a` WHERE NOT EXISTS (SELECT `C1` FROM `T3b` WHERE `T3a`.`C1` = `T3b`.`C1`);
+SELECT `C1` FROM `T4a` WHERE `C1` IN (SELECT `C1` FROM `T4b`);
+SELECT `C1` FROM `T4a` WHERE EXISTS (SELECT `C1` FROM `T4b` WHERE `T4a`.`C1` = `T4b`.`C1`);
+SELECT `C1` FROM `T4a` WHERE NOT EXISTS (SELECT `C1` FROM `T4b` WHERE `T4a`.`C1` = `T4b`.`C1`);
+SELECT `C1` FROM `T5a` WHERE `C1` IN (SELECT `C1` FROM `T5b`);
+SELECT `C1` FROM `T5a` WHERE EXISTS (SELECT `C1` FROM `T5b` WHERE `T5a`.`C1` = `T5b`.`C1`);
+SELECT `C1` FROM `T5a` WHERE NOT EXISTS (SELECT `C1` FROM `T5b` WHERE `T5a`.`C1` = `T5b`.`C1`);
+SELECT `C1` FROM `T6a` WHERE `C1` IN (SELECT `C1` FROM `T6b`);
+SELECT `C1` FROM `T6a` WHERE EXISTS (SELECT `C1` FROM `T6b` WHERE `T6a`.`C1` = `T6b`.`C1`);
+SELECT `C1` FROM `T6a` WHERE NOT EXISTS (SELECT `C1` FROM `T6b` WHERE `T6a`.`C1` = `T6b`.`C1`);
+SELECT `C1` FROM `T7a` WHERE `C1` IN (SELECT `C1` FROM `T7b`);
+SELECT `C1` FROM `T7a` WHERE EXISTS (SELECT `C1` FROM `T7b` WHERE `T7a`.`C1` = `T7b`.`C1`);
+SELECT `C1` FROM `T7a` WHERE NOT EXISTS (SELECT `C1` FROM `T7b` WHERE `T7a`.`C1` = `T7b`.`C1`);
+SELECT `C1` FROM `T8a` WHERE `C1` IN (SELECT `C1` FROM `T8b`);
+SELECT `C1` FROM `T8a` WHERE EXISTS (SELECT `C1` FROM `T8b` WHERE `T8a`.`C1` = `T8b`.`C1`);
+SELECT `C1` FROM `T8a` WHERE NOT EXISTS (SELECT `C1` FROM `T8b` WHERE `T8a`.`C1` = `T8b`.`C1`);
+SELECT `C1` FROM `T9a` WHERE `C1` IN (SELECT `C1` FROM `T9b`);
+SELECT `C1` FROM `T9a` WHERE EXISTS (SELECT `C1` FROM `T9b` WHERE `T9a`.`C1` = `T9b`.`C1`);
+SELECT `C1` FROM `T9a` WHERE NOT EXISTS (SELECT `C1` FROM `T9b` WHERE `T9a`.`C1` = `T9b`.`C1`);
+
+DROP TABLE `T1a`;
+DROP TABLE `T1b`;
+DROP TABLE `T2a`;
+DROP TABLE `T2b`;
+DROP TABLE `T3a`;
+DROP TABLE `T3b`;
+DROP TABLE `T4a`;
+DROP TABLE `T4b`;
+DROP TABLE `T5a`;
+DROP TABLE `T5b`;
+DROP TABLE `T6a`;
+DROP TABLE `T6b`;
+DROP TABLE `T7a`;
+DROP TABLE `T7b`;
+DROP TABLE `T8a`;
+DROP TABLE `T8b`;
+DROP TABLE `T9a`;
+DROP TABLE `T9b`;
diff --git a/mysql-test/suite/jp/t/jp_subquery_ucs2.test b/mysql-test/suite/jp/t/jp_subquery_ucs2.test
new file mode 100644
index 00000000..1361235f
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_subquery_ucs2.test
@@ -0,0 +1,122 @@
+--source include/have_ucs2.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS `」ヤ」アa`;
+DROP TABLE IF EXISTS `」ヤ」アb`;
+DROP TABLE IF EXISTS `」ヤ」イa`;
+DROP TABLE IF EXISTS `」ヤ」イb`;
+DROP TABLE IF EXISTS `」ヤ」ウa`;
+DROP TABLE IF EXISTS `」ヤ」ウb`;
+DROP TABLE IF EXISTS `」ヤ」エa`;
+DROP TABLE IF EXISTS `」ヤ」エb`;
+DROP TABLE IF EXISTS `」ヤ」オa`;
+DROP TABLE IF EXISTS `」ヤ」オb`;
+DROP TABLE IF EXISTS `」ヤ」カa`;
+DROP TABLE IF EXISTS `」ヤ」カb`;
+DROP TABLE IF EXISTS `」ヤ」キa`;
+DROP TABLE IF EXISTS `」ヤ」キb`;
+DROP TABLE IF EXISTS `」ヤ」クa`;
+DROP TABLE IF EXISTS `」ヤ」クb`;
+DROP TABLE IF EXISTS `」ヤ」ケa`;
+DROP TABLE IF EXISTS `」ヤ」ケb`;
+--enable_warnings
+
+#
+# Test subquery using Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」アa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」アb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」エb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」キb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」クa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」クb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ucs2 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`.`」テ」ア`);
+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`.`」テ」ア`);
+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`;
diff --git a/mysql-test/suite/jp/t/jp_subquery_ujis.test b/mysql-test/suite/jp/t/jp_subquery_ujis.test
new file mode 100644
index 00000000..1132f470
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_subquery_ujis.test
@@ -0,0 +1,121 @@
+--source include/have_ujis.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS `」ヤ」アa`;
+DROP TABLE IF EXISTS `」ヤ」アb`;
+DROP TABLE IF EXISTS `」ヤ」イa`;
+DROP TABLE IF EXISTS `」ヤ」イb`;
+DROP TABLE IF EXISTS `」ヤ」ウa`;
+DROP TABLE IF EXISTS `」ヤ」ウb`;
+DROP TABLE IF EXISTS `」ヤ」エa`;
+DROP TABLE IF EXISTS `」ヤ」エb`;
+DROP TABLE IF EXISTS `」ヤ」オa`;
+DROP TABLE IF EXISTS `」ヤ」オb`;
+DROP TABLE IF EXISTS `」ヤ」カa`;
+DROP TABLE IF EXISTS `」ヤ」カb`;
+DROP TABLE IF EXISTS `」ヤ」キa`;
+DROP TABLE IF EXISTS `」ヤ」キb`;
+DROP TABLE IF EXISTS `」ヤ」クa`;
+DROP TABLE IF EXISTS `」ヤ」クb`;
+DROP TABLE IF EXISTS `」ヤ」ケa`;
+DROP TABLE IF EXISTS `」ヤ」ケb`;
+--enable_warnings
+
+#
+# Test subquery using Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」アa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」アb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」エb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」キb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」クa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」クb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケa` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケb` (`」テ」ア` char(1) PRIMARY KEY) DEFAULT CHARSET = ujis 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`.`」テ」ア`);
+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`.`」テ」ア`);
+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`;
diff --git a/mysql-test/suite/jp/t/jp_subquery_utf8.test b/mysql-test/suite/jp/t/jp_subquery_utf8.test
new file mode 100644
index 00000000..c9df0a4a
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_subquery_utf8.test
@@ -0,0 +1,114 @@
+--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 `シエシ疎` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ礎` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ誕` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ鍛` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ殿` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ澱` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蚤` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ巴` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ病` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ秒` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ紡` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ肪` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ預` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ傭` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ和` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ話` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兮` (`シ」シ疏 char(1) PRIMARY KEY) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ冀` (`シ」シ疏 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 `シエシ疎` 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 ('鮴');
+
+#Test for innodb
+SELECT `シ」シ疏 FROM `シエシ疎` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ礎`);
+SELECT `シ」シ疏 FROM `シエシ疎` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ礎` WHERE `シエシ疎`.`シ」シ疏 = `シエシ礎`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ疎` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ礎` WHERE `シエシ疎`.`シ」シ疏 = `シエシ礎`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ誕` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ鍛`);
+SELECT `シ」シ疏 FROM `シエシ誕` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ鍛` WHERE `シエシ誕`.`シ」シ疏 = `シエシ鍛`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ誕` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ鍛` WHERE `シエシ誕`.`シ」シ疏 = `シエシ鍛`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ殿` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ澱`);
+SELECT `シ」シ疏 FROM `シエシ殿` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ澱` WHERE `シエシ殿`.`シ」シ疏 = `シエシ澱`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ殿` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ澱` WHERE `シエシ殿`.`シ」シ疏 = `シエシ澱`.`シ」シ疏);
+#Test for myisam
+SELECT `シ」シ疏 FROM `シエシ蚤` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ巴`);
+SELECT `シ」シ疏 FROM `シエシ蚤` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ巴` WHERE `シエシ蚤`.`シ」シ疏 = `シエシ巴`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ蚤` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ巴` WHERE `シエシ蚤`.`シ」シ疏 = `シエシ巴`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ病` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ秒`);
+SELECT `シ」シ疏 FROM `シエシ病` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ秒` WHERE `シエシ病`.`シ」シ疏 = `シエシ秒`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ病` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ秒` WHERE `シエシ病`.`シ」シ疏 = `シエシ秒`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ紡` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ肪`);
+SELECT `シ」シ疏 FROM `シエシ紡` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ肪` WHERE `シエシ紡`.`シ」シ疏 = `シエシ肪`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ紡` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ肪` WHERE `シエシ紡`.`シ」シ疏 = `シエシ肪`.`シ」シ疏);
+#Test for memory
+SELECT `シ」シ疏 FROM `シエシ預` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ傭`);
+SELECT `シ」シ疏 FROM `シエシ預` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ傭` WHERE `シエシ預`.`シ」シ疏 = `シエシ傭`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ預` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ傭` WHERE `シエシ預`.`シ」シ疏 = `シエシ傭`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ和` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ話`);
+SELECT `シ」シ疏 FROM `シエシ和` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ話` WHERE `シエシ和`.`シ」シ疏 = `シエシ話`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ和` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ話` WHERE `シエシ和`.`シ」シ疏 = `シエシ話`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ兮` WHERE `シ」シ疏 IN (SELECT `シ」シ疏 FROM `シエシ冀`);
+SELECT `シ」シ疏 FROM `シエシ兮` WHERE EXISTS (SELECT `シ」シ疏 FROM `シエシ冀` WHERE `シエシ兮`.`シ」シ疏 = `シエシ冀`.`シ」シ疏);
+SELECT `シ」シ疏 FROM `シエシ兮` WHERE NOT EXISTS (SELECT `シ」シ疏 FROM `シエシ冀` WHERE `シエシ兮`.`シ」シ疏 = `シエシ冀`.`シ」シ疏);
+
+DROP TABLE `シエシ疎`;
+DROP TABLE `シエシ礎`;
+DROP TABLE `シエシ誕`;
+DROP TABLE `シエシ鍛`;
+DROP TABLE `シエシ殿`;
+DROP TABLE `シエシ澱`;
+DROP TABLE `シエシ蚤`;
+DROP TABLE `シエシ巴`;
+DROP TABLE `シエシ病`;
+DROP TABLE `シエシ秒`;
+DROP TABLE `シエシ紡`;
+DROP TABLE `シエシ肪`;
+DROP TABLE `シエシ預`;
+DROP TABLE `シエシ傭`;
+DROP TABLE `シエシ和`;
+DROP TABLE `シエシ話`;
+DROP TABLE `シエシ兮`;
+DROP TABLE `シエシ冀`;
diff --git a/mysql-test/suite/jp/t/jp_substring_sjis.test b/mysql-test/suite/jp/t/jp_substring_sjis.test
new file mode 100644
index 00000000..5b956e8e
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_substring_sjis.test
@@ -0,0 +1,316 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test SUBSTRING() function with Japanese character in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T2` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T3` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T4` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T5` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T6` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+INSERT INTO `T7` VALUES ('アイウエオ'),('アイウエ'),('アイウ'),('アイ'),('ア'),('');
+INSERT INTO `T8` VALUES ('あいうえお'),('あいうえ'),('あいう'),('あい'),('あ'),('');
+INSERT INTO `T9` VALUES ('ソ十表予構'),('ソ十表予'),('ソ十表'),('ソ十'),('ソ'),('');
+
+#InnoDB
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T1`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T1`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T2`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T2`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T3`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T3`;
+
+#MyISAM
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T4`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T4`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T5`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T5`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T6`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T6`;
+
+#MEMORY
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T7`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T7`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T8`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T8`;
+
+SELECT `C1`, SUBSTRING(`C1`,0) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,2) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,3) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,4) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,5) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,6) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 0) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 2) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 3) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 4) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 5) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 6) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,0) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,1) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,2) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,3) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,4) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,5) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1`,1,6) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 0) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 1) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 2) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 3) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 4) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 5) FROM `T9`;
+SELECT `C1`, SUBSTRING(`C1` FROM 1 FOR 6) FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_substring_ucs2.test b/mysql-test/suite/jp/t/jp_substring_ucs2.test
new file mode 100644
index 00000000..febad324
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_substring_ucs2.test
@@ -0,0 +1,319 @@
+--source include/have_ucs2.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 SUBSTRING() function with Japanese character in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 ('常ワ常ン常゙常゚常'),('常ワ常ン常゙常゚'),('常ワ常ン常゙'),('常ワ常ン'),('常ワ'),('');
+
+# Test of SUBSTRING(str,pos) and SUBSTRING(str FROM pos)
+# is not available until the bug #5364 is fixed
+
+#InnoDB
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ア`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ア`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」イ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」イ`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ウ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ウ`;
+
+#MyISAM
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」エ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」エ`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」オ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」オ`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」カ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」カ`;
+
+#MEMORY
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」キ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」キ`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ク`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ク`;
+
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ケ`;
+#SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_substring_ujis.test b/mysql-test/suite/jp/t/jp_substring_ujis.test
new file mode 100644
index 00000000..df35d91c
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_substring_ujis.test
@@ -0,0 +1,315 @@
+--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 SUBSTRING() function with Japanese character in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ア`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ア`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」イ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」イ`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ウ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」エ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」エ`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」オ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」オ`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」カ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」キ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」キ`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ク`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ク`;
+
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,6) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 6) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア`,1,6) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 0) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 1) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 2) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 3) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 4) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 5) FROM `」ヤ」ケ`;
+SELECT `」テ」ア`, SUBSTRING(`」テ」ア` FROM 1 FOR 6) FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_substring_utf8.test b/mysql-test/suite/jp/t/jp_substring_utf8.test
new file mode 100644
index 00000000..5408afd8
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_substring_utf8.test
@@ -0,0 +1,314 @@
+--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 SUBSTRING() function with Japanese character in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ疏;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ疏;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ蛋;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ蛋;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ伝;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ伝;
+
+#MyISAM
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ覗;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ覗;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ描;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ描;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ冒;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ冒;
+
+#MEMORY
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ輿;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ輿;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ倭;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ倭;
+
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,0) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,2) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,3) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,4) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,5) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,6) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 0) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 2) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 3) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 4) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 5) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 6) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,0) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,1) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,2) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,3) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,4) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,5) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏,1,6) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 0) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 1) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 2) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 3) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 4) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 5) FROM `シエシ兪;
+SELECT `シ」シ疏, SUBSTRING(`シ」シ疏 FROM 1 FOR 6) FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_trim_sjis.test b/mysql-test/suite/jp/t/jp_trim_sjis.test
new file mode 100644
index 00000000..4a2b6b98
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_trim_sjis.test
@@ -0,0 +1,13 @@
+#
+# Test TRIM() function with Japanese characters sjis encoding
+#
+
+--source include/have_innodb.inc
+let $engine = innodb;
+--source suite/jp/include/trim_sjis.inc
+
+let $engine = myisam;
+--source suite/jp/include/trim_sjis.inc
+
+let $engine = memory;
+--source suite/jp/include/trim_sjis.inc
diff --git a/mysql-test/suite/jp/t/jp_trim_ucs2.test b/mysql-test/suite/jp/t/jp_trim_ucs2.test
new file mode 100644
index 00000000..e7205019
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_trim_ucs2.test
@@ -0,0 +1,173 @@
+--source include/have_ucs2.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 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 = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(12), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(12), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 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 `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_trim_ujis.test b/mysql-test/suite/jp/t/jp_trim_ujis.test
new file mode 100644
index 00000000..658d066d
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_trim_ujis.test
@@ -0,0 +1,172 @@
+--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 `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_trim_utf8.test b/mysql-test/suite/jp/t/jp_trim_utf8.test
new file mode 100644
index 00000000..fd258869
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_trim_utf8.test
@@ -0,0 +1,171 @@
+--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 TRIM() function with Japanese characters utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(12), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 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 `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_union_ujis.test b/mysql-test/suite/jp/t/jp_union_ujis.test
new file mode 100644
index 00000000..73c9c660
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_union_ujis.test
@@ -0,0 +1,103 @@
+--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 UNION with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+#InnoDB
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+INSERT INTO `」ヤ」ア` VALUES('竺'),('竺'),('、「'),('、「'),('常ワ'),('常ワ');
+INSERT INTO `」ヤ」イ` VALUES('軸'),('軸'),('、、'),('、、'),('常ン'),('常ン');
+INSERT INTO `」ヤ」ウ` VALUES('宍'),('宍'),('、ヲ'),('、ヲ'),('常゙'),('常゙');
+SELECT * FROM `」ヤ」ア` UNION DISTINCT SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+(SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) UNION (SELECT '、ヲ') ORDER BY `」テ」ア`;
+(SELECT '、ヲ' AS `」テ」ア`) UNION (SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) ORDER BY `」テ」ア`;
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」ア` GROUP BY `」テ」ア` UNION
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」イ` GROUP BY `」テ」ア` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION DISTINCT
+SELECT * FROM `」ヤ」イ` UNION ALL
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL
+SELECT * FROM `」ヤ」イ` UNION DISTINCT
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION SELECT REPEAT(`」テ」ア`,5) FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+DROP TABLE `」ヤ」ア` ;
+DROP TABLE `」ヤ」イ` ;
+DROP TABLE `」ヤ」ウ` ;
+
+#MyISAM
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MYISAM;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MYISAM;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MYISAM;
+INSERT INTO `」ヤ」ア` VALUES('竺'),('竺'),('、「'),('、「'),('常ワ'),('常ワ');
+INSERT INTO `」ヤ」イ` VALUES('軸'),('軸'),('、、'),('、、'),('常ン'),('常ン');
+INSERT INTO `」ヤ」ウ` VALUES('宍'),('宍'),('、ヲ'),('、ヲ'),('常゙'),('常゙');
+SELECT * FROM `」ヤ」ア` UNION DISTINCT SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+(SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) UNION (SELECT '、ヲ') ORDER BY `」テ」ア`;
+(SELECT '、ヲ' AS `」テ」ア`) UNION (SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) ORDER BY `」テ」ア`;
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」ア` GROUP BY `」テ」ア` UNION
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」イ` GROUP BY `」テ」ア` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION DISTINCT
+SELECT * FROM `」ヤ」イ` UNION ALL
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL
+SELECT * FROM `」ヤ」イ` UNION DISTINCT
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION SELECT REPEAT(`」テ」ア`,5) FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+DROP TABLE `」ヤ」ア` ;
+DROP TABLE `」ヤ」イ` ;
+DROP TABLE `」ヤ」ウ` ;
+
+#MEMORY
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+INSERT INTO `」ヤ」ア` VALUES('竺'),('竺'),('、「'),('、「'),('常ワ'),('常ワ');
+INSERT INTO `」ヤ」イ` VALUES('軸'),('軸'),('、、'),('、、'),('常ン'),('常ン');
+INSERT INTO `」ヤ」ウ` VALUES('宍'),('宍'),('、ヲ'),('、ヲ'),('常゙'),('常゙');
+SELECT * FROM `」ヤ」ア` UNION DISTINCT SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+(SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) UNION (SELECT '、ヲ') ORDER BY `」テ」ア`;
+(SELECT '、ヲ' AS `」テ」ア`) UNION (SELECT * FROM `」ヤ」ア`) UNION (SELECT * FROM `」ヤ」イ`) ORDER BY `」テ」ア`;
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」ア` GROUP BY `」テ」ア` UNION
+SELECT `」テ」ア`, COUNT(*) FROM `」ヤ」イ` GROUP BY `」テ」ア` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION DISTINCT
+SELECT * FROM `」ヤ」イ` UNION ALL
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL
+SELECT * FROM `」ヤ」イ` UNION DISTINCT
+SELECT * FROM `」ヤ」ウ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION SELECT REPEAT(`」テ」ア`,5) FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+DROP TABLE `」ヤ」ア` ;
+DROP TABLE `」ヤ」イ` ;
+DROP TABLE `」ヤ」ウ` ;
+
+# Test mixed strage engine
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = InnoDB;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(1), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MyISAM;
+INSERT INTO `」ヤ」ア` VALUES('竺'),('竺'),('、「'),('、「'),('常ワ'),('常ワ');
+INSERT INTO `」ヤ」イ` VALUES('軸'),('軸'),('、、'),('、、'),('常ン'),('常ン');
+SELECT * FROM `」ヤ」ア` UNION DISTINCT SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+SELECT * FROM `」ヤ」ア` UNION ALL SELECT * FROM `」ヤ」イ` ORDER BY `」テ」ア`;
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
diff --git a/mysql-test/suite/jp/t/jp_update_sjis.test b/mysql-test/suite/jp/t/jp_update_sjis.test
new file mode 100644
index 00000000..b977df5f
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_update_sjis.test
@@ -0,0 +1,76 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test Updating with Japanese characters in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(5), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+
+INSERT INTO `T1` VALUES ('アイウエオ');
+INSERT INTO `T2` VALUES ('あいうえお');
+INSERT INTO `T3` VALUES ('ソ十表予構');
+INSERT INTO `T4` VALUES ('アイウエオ');
+INSERT INTO `T5` VALUES ('あいうえお');
+INSERT INTO `T6` VALUES ('ソ十表予構');
+INSERT INTO `T7` VALUES ('アイウエオ');
+INSERT INTO `T8` VALUES ('あいうえお');
+INSERT INTO `T9` VALUES ('ソ十表予構');
+
+UPDATE `T1` SET `C1` = ('カキクケコ');
+UPDATE `T2` SET `C1` = ('かきくけこ');
+UPDATE `T3` SET `C1` = ('噂蚕申貼能');
+UPDATE `T4` SET `C1` = ('カキクケコ');
+UPDATE `T5` SET `C1` = ('かきくけこ');
+UPDATE `T6` SET `C1` = ('噂蚕申貼能');
+UPDATE `T7` SET `C1` = ('カキクケコ');
+UPDATE `T8` SET `C1` = ('かきくけこ');
+UPDATE `T9` SET `C1` = ('噂蚕申貼能');
+
+#InnoDB
+SELECT * FROM `T1`;
+SELECT * FROM `T2`;
+SELECT * FROM `T3`;
+
+#MyISAM
+SELECT * FROM `T4`;
+SELECT * FROM `T5`;
+SELECT * FROM `T6`;
+
+#MEMORY
+SELECT * FROM `T7`;
+SELECT * FROM `T8`;
+SELECT * FROM `T9`;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_update_ucs2.test b/mysql-test/suite/jp/t/jp_update_ucs2.test
new file mode 100644
index 00000000..33a5ce63
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_update_ucs2.test
@@ -0,0 +1,77 @@
+--source include/have_ucs2.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 Updating with Japanese characters in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+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 ('常ワ常ン常゙常゚常');
+
+UPDATE `」ヤ」ア` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」イ` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」ウ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+UPDATE `」ヤ」エ` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」オ` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」カ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+UPDATE `」ヤ」キ` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」ク` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」ケ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+
+#InnoDB
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_update_ujis.test b/mysql-test/suite/jp/t/jp_update_ujis.test
new file mode 100644
index 00000000..3ba00946
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_update_ujis.test
@@ -0,0 +1,76 @@
+--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 Updating with Japanese characters in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(5), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+
+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 ('常ワ常ン常゙常゚常');
+
+UPDATE `」ヤ」ア` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」イ` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」ウ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+UPDATE `」ヤ」エ` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」オ` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」カ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+UPDATE `」ヤ」キ` SET `」テ」ア` = ('叱執失嫉室');
+UPDATE `」ヤ」ク` SET `」テ」ア` = ('、ォ、ュ、ッ、ア、ウ');
+UPDATE `」ヤ」ケ` SET `」テ」ア` = ('常ネ常ノ常ハ常ヒ常フ');
+
+#InnoDB
+SELECT * FROM `」ヤ」ア`;
+SELECT * FROM `」ヤ」イ`;
+SELECT * FROM `」ヤ」ウ`;
+
+#MyISAM
+SELECT * FROM `」ヤ」エ`;
+SELECT * FROM `」ヤ」オ`;
+SELECT * FROM `」ヤ」カ`;
+
+#MEMORY
+SELECT * FROM `」ヤ」キ`;
+SELECT * FROM `」ヤ」ク`;
+SELECT * FROM `」ヤ」ケ`;
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_update_utf8.test b/mysql-test/suite/jp/t/jp_update_utf8.test
new file mode 100644
index 00000000..8dbd046a
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_update_utf8.test
@@ -0,0 +1,75 @@
+--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 Updating with Japanese characters in utf8 encoding
+#
+
+SET NAMES utf8;
+SET character_set_database = utf8;
+
+CREATE TABLE `シエシ疏 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ蛋 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ伝 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = innodb;
+CREATE TABLE `シエシ覗 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ描 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ冒 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = myisam;
+CREATE TABLE `シエシ輿 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ倭 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+CREATE TABLE `シエシ兪 (`シ」シ疏 char(5), INDEX(`シ」シ疏)) DEFAULT CHARSET = utf8 engine = MEMORY;
+
+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 ('鮴秘セ夜セ鈴セ樣セ。');
+
+UPDATE `シエシ疏 SET `シ」シ疏 = ('スカスキスクスケスコ');
+UPDATE `シエシ蛋 SET `シ」シ疏 = ('縺九″縺上¢縺');
+UPDATE `シエシ伝 SET `シ」シ疏 = ('鮨鈴ス倬ス夐ス晞ス');
+UPDATE `シエシ覗 SET `シ」シ疏 = ('スカスキスクスケスコ');
+UPDATE `シエシ描 SET `シ」シ疏 = ('縺九″縺上¢縺');
+UPDATE `シエシ冒 SET `シ」シ疏 = ('鮨鈴ス倬ス夐ス晞ス');
+UPDATE `シエシ輿 SET `シ」シ疏 = ('スカスキスクスケスコ');
+UPDATE `シエシ倭 SET `シ」シ疏 = ('縺九″縺上¢縺');
+UPDATE `シエシ兪 SET `シ」シ疏 = ('鮨鈴ス倬ス夐ス晞ス');
+
+#InnoDB
+SELECT * FROM `シエシ疏;
+SELECT * FROM `シエシ蛋;
+SELECT * FROM `シエシ伝;
+
+#MyISAM
+SELECT * FROM `シエシ覗;
+SELECT * FROM `シエシ描;
+SELECT * FROM `シエシ冒;
+
+#MEMORY
+SELECT * FROM `シエシ輿;
+SELECT * FROM `シエシ倭;
+SELECT * FROM `シエシ兪;
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;
diff --git a/mysql-test/suite/jp/t/jp_where_sjis.test b/mysql-test/suite/jp/t/jp_where_sjis.test
new file mode 100644
index 00000000..37490572
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_where_sjis.test
@@ -0,0 +1,93 @@
+--source include/have_sjis.inc
+--source include/have_innodb.inc
+--character_set sjis
+--disable_warnings
+drop table if exists `T1`;
+drop table if exists `T2`;
+drop table if exists `T3`;
+drop table if exists `T4`;
+drop table if exists `T5`;
+drop table if exists `T6`;
+drop table if exists `T7`;
+drop table if exists `T8`;
+drop table if exists `T9`;
+--enable_warnings
+
+#
+# Test Displaying Japanese charact using WHERE condtion in sjis encoding
+#
+
+SET NAMES sjis;
+SET character_set_database = sjis;
+
+CREATE TABLE `T1` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T2` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T3` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = innodb;
+CREATE TABLE `T4` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T5` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T6` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = myisam;
+CREATE TABLE `T7` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T8` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis engine = MEMORY;
+CREATE TABLE `T9` (`C1` char(20), INDEX(`C1`)) DEFAULT CHARSET = sjis 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_sjis.dat' INTO TABLE `T1`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T2`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T3`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T4`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T5`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T6`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_sjis.dat' INTO TABLE `T7`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis.dat' INTO TABLE `T8`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_sjis2.dat' INTO TABLE `T9`;
+
+#InnoDB
+SELECT * FROM `T1` WHERE `C1` = 'ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T2` WHERE `C1` = '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T3` WHERE `C1` = 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+#MyISAM
+SELECT * FROM `T4` WHERE `C1` = 'ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T5` WHERE `C1` = '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T6` WHERE `C1` = 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+#MEMORY
+SELECT * FROM `T7` WHERE `C1` = 'ーアイウエオカキクケコサシスセソ';
+SELECT * FROM `T8` WHERE `C1` = '・ぁあぃいぅうぇえぉおかがきぎくぐけげこ';
+SELECT * FROM `T9` WHERE `C1` = 'ソ十表予構噂蚕申貼能暴禄曾箪兔喀媾彌拿杤';
+
+#Test to distinguish 0x9353 and 0x9373
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+CREATE TABLE t1(c1 char(1)) default charset = sjis engine=innodb;
+CREATE TABLE t2(c1 char(1)) default charset = sjis engine=myisam;
+CREATE TABLE t3(c1 char(1)) default charset = sjis engine=MEMORY;
+INSERT INTO t1 VALUES('鉄'),('都');
+INSERT INTO t2 VALUES('鉄'),('都');
+INSERT INTO t3 VALUES('鉄'),('都');
+SELECT * FROM t1 WHERE c1 = '鉄';
+SELECT * FROM t2 WHERE c1 = '鉄';
+SELECT * FROM t3 WHERE c1 = '鉄';
+SELECT * FROM t1 WHERE c1 = '都';
+SELECT * FROM t2 WHERE c1 = '都';
+SELECT * FROM t3 WHERE c1 = '都';
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+DROP TABLE `T1`;
+DROP TABLE `T2`;
+DROP TABLE `T3`;
+DROP TABLE `T4`;
+DROP TABLE `T5`;
+DROP TABLE `T6`;
+DROP TABLE `T7`;
+DROP TABLE `T8`;
+DROP TABLE `T9`;
diff --git a/mysql-test/suite/jp/t/jp_where_ucs2.test b/mysql-test/suite/jp/t/jp_where_ucs2.test
new file mode 100644
index 00000000..7e035cd2
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_where_ucs2.test
@@ -0,0 +1,137 @@
+--source include/have_ucs2.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 Displaying Japanese charact using WHERE condtion in ucs2 encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ucs2;
+SET collation_connection = ucs2_general_ci;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ucs2 engine = MEMORY;
+
+#Insert the following data in each table
+# jisx0201 hankaku-katakana data
+# jisx0208 data
+# jisx0212 supplemental character data
+
+INSERT INTO `」ヤ」ア` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」イ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ウ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」エ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」オ` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」カ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+INSERT INTO `」ヤ」キ` VALUES
+ ('PQRSTUVWXYZ[\\]^_')
+,(' 治爾璽痔磁示而耳自蒔辞汐鹿式識')
+,('鴫竺軸宍雫七叱執失嫉室悉湿漆疾質')
+,('実蔀篠偲柴芝屡蕊縞舎写射捨赦斜煮')
+,('社紗者謝車遮蛇邪借勺尺杓灼爵酌釈');
+
+INSERT INTO `」ヤ」ク` VALUES
+ ('。エ。オ。カ。キ。ク。ケ。コ。サ。シ。ス。セ。ソ。タ。チ。ツ。テ。ト。ナ。ニ。ヌ')
+,('。ネ。ノ。ハ。ヒ。フ。ヘ。ホ。マ。ミ。ム。メ。モ。ヤ。ユ。ヨ。ラ。リ。ル。レ。ロ')
+,('。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ')
+,('。ヲ・。・「・」・、・・・ヲ・ァ・ィ・ゥ・ェ・ォ・ャ・ュ・ョ・ッ・ー・ア・イ・ウ')
+,('。ヲー。ー「ー」ー、ー・ーヲーァーィーゥーェーォーャーューョーッーーーアーイーウ')
+,('。ヲミ。ミ「ミ」ミ、ミ・ミヲミァミィミゥミェミォミャミュミョミッミーミアミイミウ')
+,('。ヲ。「」、・ヲァィゥェォャュョッーアイウ');
+
+INSERT INTO `」ヤ」ケ` VALUES
+ ('。ヲ召オ召カ召キ召ク召ケ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ。ヲ召ツ召テ召ト。ヲ。ヲ。ヲ')
+,('床エ床オ床カ床キ床ク床ケ床コ床サ床シ床ス床セ床ソ床タ床チ床ツ床テ床ト床ナ床ニ床ヌ')
+,('床ネ床ノ床ハ床ヒ床フ床ヘ床ホ床マ床ミ床ム床メ床モ床ヤ床ユ床ヨ床ラ床リ床ル床レ床ロ')
+,('床ワ床ン床゙床゚床熄ー瘴ー竢ー繽ー苡ー蜿ー謠ー迴ー闖ー髀ー齒ー床床床床')
+,('。ヲ常。常「常」常、常・常ヲ常ァ常ィ常ゥ常ェ常ォ常ャ常ュ常ョ常ッ常ー常ア常イ常ウ')
+,('常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ')
+,('常ネ常ノ常ハ常ヒ常フ常ヘ常ホ常マ常ミ常ム常メ常モ常ヤ常ユ常ヨ常ラ常リ常ル常レ常ロ');
+
+#InnoDB
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MyISAM
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MEMORY
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_where_ujis.test b/mysql-test/suite/jp/t/jp_where_ujis.test
new file mode 100644
index 00000000..ce39e267
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_where_ujis.test
@@ -0,0 +1,71 @@
+--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 Displaying Japanese charact using WHERE condtion in ujis encoding
+#
+
+SET NAMES ujis;
+SET character_set_database = ujis;
+
+CREATE TABLE `」ヤ」ア` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」イ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」ウ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = innodb;
+CREATE TABLE `」ヤ」エ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」オ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」カ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = myisam;
+CREATE TABLE `」ヤ」キ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ク` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis engine = MEMORY;
+CREATE TABLE `」ヤ」ケ` (`」テ」ア` char(20), INDEX(`」テ」ア`)) DEFAULT CHARSET = ujis 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_ujis.dat' INTO TABLE `」ヤ」ア`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」イ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ウ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」エ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」オ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」カ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0201_ujis.dat' INTO TABLE `」ヤ」キ`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0208_ujis.dat' INTO TABLE `」ヤ」ク`;
+LOAD DATA LOCAL INFILE 'suite/jp/std_data/jisx0212_ujis.dat' INTO TABLE `」ヤ」ケ`;
+
+#InnoDB
+SELECT * FROM `」ヤ」ア` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」イ` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ウ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MyISAM
+SELECT * FROM `」ヤ」エ` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」オ` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」カ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+#MEMORY
+SELECT * FROM `」ヤ」キ` WHERE `」テ」ア` = '鴫竺軸宍雫七叱執失嫉室悉湿漆疾質';
+SELECT * FROM `」ヤ」ク` WHERE `」テ」ア` = '。ヲ、。、「、」、、、・、ヲ、ァ、ィ、ゥ、ェ、ォ、ャ、ュ、ョ、ッ、ー、ア、イ、ウ';
+SELECT * FROM `」ヤ」ケ` WHERE `」テ」ア` = '常エ常オ常カ常キ常ク常ケ常コ常サ常シ常ス常セ常ソ常タ常チ常ツ常テ常ト常ナ常ニ常ヌ';
+
+DROP TABLE `」ヤ」ア`;
+DROP TABLE `」ヤ」イ`;
+DROP TABLE `」ヤ」ウ`;
+DROP TABLE `」ヤ」エ`;
+DROP TABLE `」ヤ」オ`;
+DROP TABLE `」ヤ」カ`;
+DROP TABLE `」ヤ」キ`;
+DROP TABLE `」ヤ」ク`;
+DROP TABLE `」ヤ」ケ`;
diff --git a/mysql-test/suite/jp/t/jp_where_utf8.test b/mysql-test/suite/jp/t/jp_where_utf8.test
new file mode 100644
index 00000000..97234ff1
--- /dev/null
+++ b/mysql-test/suite/jp/t/jp_where_utf8.test
@@ -0,0 +1,70 @@
+--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 Displaying Japanese charact using WHERE condition 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 * FROM `シエシ疏 WHERE `シ」シ疏 = 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ蛋 WHERE `シ」シ疏 = '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ伝 WHERE `シ」シ疏 = '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+#MyISAM
+SELECT * FROM `シエシ覗 WHERE `シ」シ疏 = 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ描 WHERE `シ」シ疏 = '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ冒 WHERE `シ」シ疏 = '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+#MEMORY
+SELECT * FROM `シエシ輿 WHERE `シ」シ疏 = 'スースアスイスウスエスオスカスキスクスケスコスサスシスススセスソ';
+SELECT * FROM `シエシ倭 WHERE `シ」シ疏 = '繝サ縺√≠縺縺縺縺縺縺医♂縺翫°縺後″縺弱¥縺舌¢縺偵%';
+SELECT * FROM `シエシ兪 WHERE `シ」シ疏 = '鮠ォ鮠ッ鮠ア鮠イ鮠エ鮠キ鮠ケ鮠コ鮠シ鮠ス鮠ソ鮨鮨鮨鮨鮨鮨鮨馴ス暮ス';
+
+DROP TABLE `シエシ疏;
+DROP TABLE `シエシ蛋;
+DROP TABLE `シエシ伝;
+DROP TABLE `シエシ覗;
+DROP TABLE `シエシ描;
+DROP TABLE `シエシ冒;
+DROP TABLE `シエシ輿;
+DROP TABLE `シエシ倭;
+DROP TABLE `シエシ兪;