summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-09-23 14:19:07 +0400
committerAlexander Barkov <bar@mariadb.org>2016-09-23 14:19:07 +0400
commit0f8a1a314d49adfe8e20c5e4d3e98e37b91b068e (patch)
tree285928478f93a3237cda86e935603a022f515a8e
parent6304c0bfc7242ad54d93168e97e82022765934e3 (diff)
downloadmariadb-git-0f8a1a314d49adfe8e20c5e4d3e98e37b91b068e.tar.gz
MDEV-10877 xxx_unicode_nopad_ci collations
-rw-r--r--include/m_ctype.h5
-rw-r--r--mysql-test/r/ctype_ldml.result37
-rw-r--r--mysql-test/r/ctype_ucs2_uca.result564
-rw-r--r--mysql-test/r/ctype_utf16_uca.result564
-rw-r--r--mysql-test/r/ctype_utf32_uca.result564
-rw-r--r--mysql-test/r/ctype_utf8_uca.result564
-rw-r--r--mysql-test/r/ctype_utf8mb4_uca.result564
-rw-r--r--mysql-test/std_data/ldml/Index.xml2
-rw-r--r--mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result10
-rw-r--r--mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result10
-rw-r--r--mysql-test/suite/innodb/r/innodb_ctype_ldml.result2
-rw-r--r--mysql-test/t/ctype_ldml.test17
-rw-r--r--mysql-test/t/ctype_ucs2_uca.test21
-rw-r--r--mysql-test/t/ctype_utf16_uca.test20
-rw-r--r--mysql-test/t/ctype_utf32_uca.test21
-rw-r--r--mysql-test/t/ctype_utf8_uca.test20
-rw-r--r--mysql-test/t/ctype_utf8mb4_uca.test20
-rw-r--r--mysys/charset-def.c15
-rw-r--r--mysys/charset.c20
-rw-r--r--strings/ctype-uca.c541
20 files changed, 3553 insertions, 28 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 9812e9fa2eb..c50763ed570 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -634,6 +634,7 @@ extern struct charset_info_st my_charset_ucs2_nopad_bin;
extern struct charset_info_st my_charset_ucs2_general_nopad_ci;
extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
extern struct charset_info_st my_charset_ucs2_unicode_ci;
+extern struct charset_info_st my_charset_ucs2_unicode_nopad_ci;
extern struct charset_info_st my_charset_ucs2_general_mysql500_ci;
extern struct charset_info_st my_charset_ujis_bin;
extern struct charset_info_st my_charset_ujis_japanese_ci;
@@ -642,6 +643,7 @@ extern struct charset_info_st my_charset_ujis_japanese_nopad_ci;
extern struct charset_info_st my_charset_utf16_bin;
extern struct charset_info_st my_charset_utf16_general_ci;
extern struct charset_info_st my_charset_utf16_unicode_ci;
+extern struct charset_info_st my_charset_utf16_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf16le_bin;
extern struct charset_info_st my_charset_utf16le_general_ci;
extern struct charset_info_st my_charset_utf16_general_nopad_ci;
@@ -651,6 +653,7 @@ extern struct charset_info_st my_charset_utf16le_general_nopad_ci;
extern struct charset_info_st my_charset_utf32_bin;
extern struct charset_info_st my_charset_utf32_general_ci;
extern struct charset_info_st my_charset_utf32_unicode_ci;
+extern struct charset_info_st my_charset_utf32_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf32_nopad_bin;
extern struct charset_info_st my_charset_utf32_general_nopad_ci;
extern struct charset_info_st my_charset_utf8_bin;
@@ -658,11 +661,13 @@ extern struct charset_info_st my_charset_utf8_nopad_bin;
extern struct charset_info_st my_charset_utf8_general_nopad_ci;
extern struct charset_info_st my_charset_utf8_general_mysql500_ci;
extern struct charset_info_st my_charset_utf8_unicode_ci;
+extern struct charset_info_st my_charset_utf8_unicode_nopad_ci;
extern struct charset_info_st my_charset_utf8mb4_bin;
extern struct charset_info_st my_charset_utf8mb4_general_ci;
extern struct charset_info_st my_charset_utf8mb4_nopad_bin;
extern struct charset_info_st my_charset_utf8mb4_general_nopad_ci;
extern struct charset_info_st my_charset_utf8mb4_unicode_ci;
+extern struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci;
#define MY_UTF8MB3 "utf8"
#define MY_UTF8MB4 "utf8mb4"
diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result
index 12a03a872e0..34e862d0222 100644
--- a/mysql-test/r/ctype_ldml.result
+++ b/mysql-test/r/ctype_ldml.result
@@ -465,6 +465,7 @@ ascii2_nopad_bin ascii2 325 1
utf8mb4_test_ci utf8mb4 326 8
utf16_test_ci utf16 327 8
utf8mb4_test_400_ci utf8mb4 328 8
+utf8mb4_test_520_nopad_ci utf8mb4 329 8
latin1_test2 latin1 332 1
latin1_test2_cs latin1 333 1
latin1_swedish_nopad2_ci latin1 334 1
@@ -493,6 +494,7 @@ utf8_test_ci utf8 353 8
ucs2_test_ci ucs2 358 8
utf8mb4_test_ci utf8mb4 326 8
utf8mb4_test_400_ci utf8mb4 328 8
+utf8mb4_test_520_nopad_ci utf8mb4 329 8
utf16_test_ci utf16 327 8
utf32_test_ci utf32 391 8
show collation like 'ucs2_vn_ci';
@@ -1289,3 +1291,38 @@ a 0 1 6120 a A a
A 1 0 41 a A A
A 0 1 4120 a A A
DROP TABLE t1;
+#
+# MDEV-10877 xxx_unicode_nopad_ci collations
+#
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_test_520_nopad_ci);
+INSERT INTO t1 VALUES ('a'),('b'),('a '),('b ');
+SELECT
+HEX(a),
+WEIGHT_STRING(a)=WEIGHT_STRING(a COLLATE utf8mb4_unicode_ci) AS is_400,
+WEIGHT_STRING(a)=WEIGHT_STRING(a COLLATE utf8mb4_unicode_520_ci) AS is_520
+FROM t1
+ORDER BY a;
+HEX(a) is_400 is_520
+61 0 1
+6120 0 1
+62 0 1
+6220 0 1
+SELECT COUNT(DISTINCT a) FROM t1;
+COUNT(DISTINCT a)
+4
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 WHERE a='a';
+HEX(a) REPLACE(a,' ','<SP>')
+61 a
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 ORDER BY a;
+HEX(a) REPLACE(a,' ','<SP>')
+61 a
+6120 a<SP>
+62 b
+6220 b<SP>
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 ORDER BY a DESC;
+HEX(a) REPLACE(a,' ','<SP>')
+6220 b<SP>
+62 b
+6120 a<SP>
+61 a
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_ucs2_uca.result b/mysql-test/r/ctype_ucs2_uca.result
new file mode 100644
index 00000000000..48ec25b32e3
--- /dev/null
+++ b/mysql-test/r/ctype_ucs2_uca.result
@@ -0,0 +1,564 @@
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-10877 xxx_unicode_nopad_ci collations
+#
+SET NAMES utf8, character_set_connection=ucs2;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'ucs2_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE ucs2_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE=ucs2_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'ucs2_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'ucs2_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'ucs2_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'ucs2_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE ucs2_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=ucs2 COLLATE=ucs2_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'ucs2_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'ucs2_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'ucs2_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'ucs2_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'ucs2_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'ucs2_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE ucs2_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE=ucs2_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'ucs2_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'ucs2_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE ucs2_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=ucs2 COLLATE=ucs2_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'ucs2_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'ucs2_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'ucs2_unicode_520_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'ucs2_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'ucs2_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'ucs2_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result
index 1e4c77ea83d..0c478222650 100644
--- a/mysql-test/r/ctype_utf16_uca.result
+++ b/mysql-test/r/ctype_utf16_uca.result
@@ -7305,3 +7305,567 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-10877 xxx_unicode_nopad_ci collations
+#
+SET NAMES utf8, character_set_connection=utf16;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf16_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf16_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf16_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf16_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf16_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf16_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf16_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf16_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf16_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf16_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf16_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf16_unicode_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf16_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf16_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf16_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf16_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf16_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf16_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf16_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf16_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+00200061 a
+002000610020 a
+0061002000200020 a
+006100620063 abc
+00610062006300200020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+00610062006300200020 abc
+006100620063 abc
+0061002000200020 a
+002000610020 a
+00200061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+00610020 a
+0061002000200020 a
+006100620063 abc
+0061006200630020 abc
+00610062006300200020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+00200061 a
+002000610020 a
+0061 a
+006100200020 a
+0061002000200020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+0061002000200020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf16_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+00610061 1
+0061006100200020 1
+00610062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf16_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf16_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf16_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '))
+0061006200630020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf16_unicode_520_nopad_ci', 'abc '))
+00610062006300200020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf16_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf16_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf16_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result
index 234a01bb108..08b0dbe999a 100644
--- a/mysql-test/r/ctype_utf32_uca.result
+++ b/mysql-test/r/ctype_utf32_uca.result
@@ -7325,3 +7325,567 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-10877 xxx_unicode_nopad_ci collations
+#
+SET NAMES utf8, character_set_connection=utf32;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf32_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf32_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE=utf32_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+0000006100000062000000630000002000000020 abc
+000000610000006200000063 abc
+00000061000000200000002000000020 a
+000000200000006100000020 a
+0000002000000061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+0000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+00000061000000620000006300000020 abc
+0000006100000062000000630000002000000020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061 a
+000000610000002000000020 a
+00000061000000200000002000000020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+00000061000000200000002000000020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+0000006100000061 1
+00000061000000610000002000000020 1
+0000006100000062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf32_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf32_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '))
+00000061000000620000006300000020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '))
+0000006100000062000000630000002000000020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf32_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf32_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf32_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf32 COLLATE=utf32_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+0000006100000062000000630000002000000020 abc
+000000610000006200000063 abc
+00000061000000200000002000000020 a
+000000200000006100000020 a
+0000002000000061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+0000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+00000061000000620000006300000020 abc
+0000006100000062000000630000002000000020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061 a
+000000610000002000000020 a
+00000061000000200000002000000020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+00000061000000200000002000000020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf32_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+0000006100000061 1
+00000061000000610000002000000020 1
+0000006100000062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf32_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf32_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf32_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '))
+00000061000000620000006300000020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf32_unicode_nopad_ci', 'abc '))
+0000006100000062000000630000002000000020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf32_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf32_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf32_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE=utf32_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+0000006100000062000000630000002000000020 abc
+000000610000006200000063 abc
+00000061000000200000002000000020 a
+000000200000006100000020 a
+0000002000000061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+0000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+00000061000000620000006300000020 abc
+0000006100000062000000630000002000000020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061 a
+000000610000002000000020 a
+00000061000000200000002000000020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+00000061000000200000002000000020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+0000006100000061 1
+00000061000000610000002000000020 1
+0000006100000062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf32_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf32_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '))
+00000061000000620000006300000020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '))
+0000006100000062000000630000002000000020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf32_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf32_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf32_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf32 COLLATE=utf32_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+0000006100000062000000630000002000000020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+0000006100000062000000630000002000000020 abc
+000000610000006200000063 abc
+00000061000000200000002000000020 a
+000000200000006100000020 a
+0000002000000061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+0000006100000020 a
+00000061000000200000002000000020 a
+000000610000006200000063 abc
+00000061000000620000006300000020 abc
+0000006100000062000000630000002000000020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+0000002000000061 a
+000000200000006100000020 a
+00000061 a
+000000610000002000000020 a
+00000061000000200000002000000020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+00000061000000200000002000000020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf32_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+0000006100000061 1
+00000061000000610000002000000020 1
+0000006100000062 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf32_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf32_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf32_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '))
+00000061000000620000006300000020
+SELECT HEX(GREATEST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf32_unicode_520_nopad_ci', 'abc '))
+0000006100000062000000630000002000000020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf32_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf32_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf32_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/r/ctype_utf8_uca.result b/mysql-test/r/ctype_utf8_uca.result
new file mode 100644
index 00000000000..c8107da3b6f
--- /dev/null
+++ b/mysql-test/r/ctype_utf8_uca.result
@@ -0,0 +1,564 @@
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-10877 xxx_unicode_nopad_ci collations
+#
+SET NAMES utf8;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8_unicode_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8_unicode_520_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/r/ctype_utf8mb4_uca.result b/mysql-test/r/ctype_utf8mb4_uca.result
index 4792d746709..c03aaef387a 100644
--- a/mysql-test/r/ctype_utf8mb4_uca.result
+++ b/mysql-test/r/ctype_utf8mb4_uca.result
@@ -6015,3 +6015,567 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-9711 NO PAD Collatons
+#
+SET NAMES utf8mb4;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8mb4_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8mb4_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8mb4_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8mb4_unicode_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8mb4_unicode_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8mb4_unicode_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+0E33020002000200020002000200020002000200
+0E33020902090200020002000200020002000200
+02090E3302000200020002000200020002000200
+02090E3302090200020002000200020002000200
+0E33020902090209020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8mb4_unicode_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+SET STORAGE_ENGINE=MyISAM;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8mb4_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=HEAP;
+#
+# Start of ctype_pad.inc
+#
+#
+# Unique indexes
+#
+CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(10) COLLATE utf8mb4_unicode_520_nopad_ci NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_nopad_ci
+INSERT INTO t1 VALUES ('abc'),('abc '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM t1 ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a;
+HEX(a) a
+2061 a
+206120 a
+61202020 a
+616263 abc
+6162632020 abc
+SELECT HEX(a), a FROM t1 IGNORE INDEX(PRIMARY) ORDER BY a DESC;
+HEX(a) a
+6162632020 abc
+616263 abc
+61202020 a
+206120 a
+2061 a
+#
+# UNION
+#
+CREATE TABLE t2 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT INTO t2 VALUES ('abc '),('abc '),(' a'),('a ');
+SELECT HEX(a),a FROM (SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+6120 a
+61202020 a
+616263 abc
+61626320 abc
+6162632020 abc
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# DISTINCT, COUNT, MAX
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT INTO t1 VALUES ('a'),('a '),(' a'),(' a '),('a ');
+SELECT HEX(a), a FROM (SELECT DISTINCT a FROM t1 ORDER BY a) td;
+HEX(a) a
+2061 a
+206120 a
+61 a
+612020 a
+61202020 a
+SELECT COUNT(DISTINCT a) FROM t1 ORDER BY a;
+COUNT(DISTINCT a)
+5
+SELECT HEX(MAX(a)), MAX(a) FROM t1;
+HEX(MAX(a)) MAX(a)
+61202020 a
+#
+# GROUP BY
+#
+CREATE TABLE t2 (a VARCHAR(10), b int, c varchar(10)) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+INSERT t2 values('ab', 12, 'cd'), ('ab', 2, 'ed'), ('aa', 20, 'er'), ('aa ', 0, 'er ');
+SELECT HEX(a), cnt FROM (SELECT a, COUNT(a) AS cnt FROM t2 GROUP BY a ORDER BY a) AS td;
+HEX(a) cnt
+6161 1
+61612020 1
+6162 2
+DROP TABLE t2;
+#
+# Weights
+#
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+HEX(WEIGHT_STRING(a AS CHAR(10)))
+120F020002000200020002000200020002000200
+120F020A020A0200020002000200020002000200
+020A120F02000200020002000200020002000200
+020A120F020A0200020002000200020002000200
+120F020A020A020A020002000200020002000200
+DROP TABLE t1;
+#
+# IF, CASE, LEAST
+#
+SELECT IF('abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad');
+IF('abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ', 'pad', 'nopad')
+nopad
+SELECT CASE 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' WHEN 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END;
+CASE WHEN 'abc' COLLATE 'utf8mb4_unicode_520_nopad_ci' = 'abc ' THEN 'pad' ELSE 'nopad' END
+nopad
+SELECT HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '));
+HEX(LEAST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '))
+61626320
+SELECT HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '));
+HEX(GREATEST('abc ' COLLATE 'utf8mb4_unicode_520_nopad_ci', 'abc '))
+6162632020
+#
+# Collation mix
+#
+CREATE TABLE t1 (a VARCHAR(10)) COLLATE 'utf8mb4_unicode_520_ci';
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_nopad_ci';
+COUNT(*)
+1
+ALTER TABLE t1 MODIFY a VARCHAR(10) COLLATE 'utf8mb4_unicode_520_nopad_ci';
+SELECT COUNT(*) FROM t1 WHERE a='a';
+COUNT(*)
+1
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_ci';
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 WHERE a='a' COLLATE 'utf8mb4_unicode_520_nopad_ci';
+COUNT(*)
+1
+DROP TABLE t1;
+#
+# End of ctype_pad.inc
+#
+SET STORAGE_ENGINE=Default;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/std_data/ldml/Index.xml b/mysql-test/std_data/ldml/Index.xml
index bf1b3e82bbf..55e754c7009 100644
--- a/mysql-test/std_data/ldml/Index.xml
+++ b/mysql-test/std_data/ldml/Index.xml
@@ -170,6 +170,8 @@
<rules>
</rules>
</collation>
+ <collation name="utf8mb4_test_520_nopad_ci" id="329" version="5.2.0" flag="nopad">
+ </collation>
</charset>
<charset name="utf16">
diff --git a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
index 2dffc7dcbb8..a7217ba424e 100644
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_ascii.result
@@ -129,6 +129,8 @@ utf8_myanmar_ci utf8 577 # #
utf8_thai_520_w2 utf8 578 # #
utf8_general_nopad_ci utf8 1057 # #
utf8_nopad_bin utf8 1107 # #
+utf8_unicode_nopad_ci utf8 1216 # #
+utf8_unicode_520_nopad_ci utf8 1238 # #
ucs2_general_ci ucs2 35 Yes # #
ucs2_bin ucs2 90 # #
ucs2_unicode_ci ucs2 128 # #
@@ -161,6 +163,8 @@ ucs2_myanmar_ci ucs2 641 # #
ucs2_thai_520_w2 ucs2 642 # #
ucs2_general_nopad_ci ucs2 1059 # #
ucs2_nopad_bin ucs2 1114 # #
+ucs2_unicode_nopad_ci ucs2 1152 # #
+ucs2_unicode_520_nopad_ci ucs2 1174 # #
cp866_general_ci cp866 36 Yes # #
cp866_bin cp866 68 # #
cp866_general_nopad_ci cp866 1060 # #
@@ -218,6 +222,8 @@ utf8mb4_myanmar_ci utf8mb4 609 # #
utf8mb4_thai_520_w2 utf8mb4 610 # #
utf8mb4_general_nopad_ci utf8mb4 1069 # #
utf8mb4_nopad_bin utf8mb4 1070 # #
+utf8mb4_unicode_nopad_ci utf8mb4 1248 # #
+utf8mb4_unicode_520_nopad_ci utf8mb4 1270 # #
cp1251_bulgarian_ci cp1251 14 # #
cp1251_ukrainian_ci cp1251 23 # #
cp1251_bin cp1251 50 # #
@@ -256,6 +262,8 @@ utf16_myanmar_ci utf16 673 # #
utf16_thai_520_w2 utf16 674 # #
utf16_general_nopad_ci utf16 1078 # #
utf16_nopad_bin utf16 1079 # #
+utf16_unicode_nopad_ci utf16 1125 # #
+utf16_unicode_520_nopad_ci utf16 1147 # #
utf16le_general_ci utf16le 56 Yes # #
utf16le_bin utf16le 62 # #
utf16le_general_nopad_ci utf16le 1080 # #
@@ -300,6 +308,8 @@ utf32_myanmar_ci utf32 737 # #
utf32_thai_520_w2 utf32 738 # #
utf32_general_nopad_ci utf32 1084 # #
utf32_nopad_bin utf32 1085 # #
+utf32_unicode_nopad_ci utf32 1184 # #
+utf32_unicode_520_nopad_ci utf32 1206 # #
binary binary 63 Yes # #
geostd8_general_ci geostd8 92 Yes # #
geostd8_bin geostd8 93 # #
diff --git a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
index 6e32c25284e..8304b3a0f96 100644
--- a/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
+++ b/mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result
@@ -129,6 +129,8 @@ utf8_myanmar_ci utf8 577 # #
utf8_thai_520_w2 utf8 578 # #
utf8_general_nopad_ci utf8 1057 # #
utf8_nopad_bin utf8 1107 # #
+utf8_unicode_nopad_ci utf8 1216 # #
+utf8_unicode_520_nopad_ci utf8 1238 # #
ucs2_general_ci ucs2 35 Yes # #
ucs2_bin ucs2 90 # #
ucs2_unicode_ci ucs2 128 # #
@@ -161,6 +163,8 @@ ucs2_myanmar_ci ucs2 641 # #
ucs2_thai_520_w2 ucs2 642 # #
ucs2_general_nopad_ci ucs2 1059 # #
ucs2_nopad_bin ucs2 1114 # #
+ucs2_unicode_nopad_ci ucs2 1152 # #
+ucs2_unicode_520_nopad_ci ucs2 1174 # #
cp866_general_ci cp866 36 Yes # #
cp866_bin cp866 68 # #
cp866_general_nopad_ci cp866 1060 # #
@@ -218,6 +222,8 @@ utf8mb4_myanmar_ci utf8mb4 609 # #
utf8mb4_thai_520_w2 utf8mb4 610 # #
utf8mb4_general_nopad_ci utf8mb4 1069 # #
utf8mb4_nopad_bin utf8mb4 1070 # #
+utf8mb4_unicode_nopad_ci utf8mb4 1248 # #
+utf8mb4_unicode_520_nopad_ci utf8mb4 1270 # #
cp1251_bulgarian_ci cp1251 14 # #
cp1251_ukrainian_ci cp1251 23 # #
cp1251_bin cp1251 50 # #
@@ -256,6 +262,8 @@ utf16_myanmar_ci utf16 673 # #
utf16_thai_520_w2 utf16 674 # #
utf16_general_nopad_ci utf16 1078 # #
utf16_nopad_bin utf16 1079 # #
+utf16_unicode_nopad_ci utf16 1125 # #
+utf16_unicode_520_nopad_ci utf16 1147 # #
utf16le_general_ci utf16le 56 Yes # #
utf16le_bin utf16le 62 # #
utf16le_general_nopad_ci utf16le 1080 # #
@@ -300,6 +308,8 @@ utf32_myanmar_ci utf32 737 # #
utf32_thai_520_w2 utf32 738 # #
utf32_general_nopad_ci utf32 1084 # #
utf32_nopad_bin utf32 1085 # #
+utf32_unicode_nopad_ci utf32 1184 # #
+utf32_unicode_520_nopad_ci utf32 1206 # #
binary binary 63 Yes # #
geostd8_general_ci geostd8 92 Yes # #
geostd8_bin geostd8 93 # #
diff --git a/mysql-test/suite/innodb/r/innodb_ctype_ldml.result b/mysql-test/suite/innodb/r/innodb_ctype_ldml.result
index a4ee090020d..375d8b72f3c 100644
--- a/mysql-test/suite/innodb/r/innodb_ctype_ldml.result
+++ b/mysql-test/suite/innodb/r/innodb_ctype_ldml.result
@@ -401,6 +401,7 @@ ascii2_nopad_bin ascii2 325 1
utf8mb4_test_ci utf8mb4 326 8
utf16_test_ci utf16 327 8
utf8mb4_test_400_ci utf8mb4 328 8
+utf8mb4_test_520_nopad_ci utf8mb4 329 8
latin1_test2 latin1 332 1
latin1_test2_cs latin1 333 1
latin1_swedish_nopad2_ci latin1 334 1
@@ -429,6 +430,7 @@ utf8_test_ci utf8 353 8
ucs2_test_ci ucs2 358 8
utf8mb4_test_ci utf8mb4 326 8
utf8mb4_test_400_ci utf8mb4 328 8
+utf8mb4_test_520_nopad_ci utf8mb4 329 8
utf16_test_ci utf16 327 8
utf32_test_ci utf32 391 8
show collation like 'ucs2_vn_ci';
diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test
index e511d7aefc8..956e48ba4af 100644
--- a/mysql-test/t/ctype_ldml.test
+++ b/mysql-test/t/ctype_ldml.test
@@ -482,3 +482,20 @@ SELECT a, a='a', a='a ', HEX(a), LOWER(a), UPPER(a), CONVERT(a USING utf8) FROM
ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_nopad2_ci;
SELECT a, a='a', a='a ', HEX(a), LOWER(a), UPPER(a), CONVERT(a USING utf8) FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-10877 xxx_unicode_nopad_ci collations
+--echo #
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_test_520_nopad_ci);
+INSERT INTO t1 VALUES ('a'),('b'),('a '),('b ');
+SELECT
+ HEX(a),
+ WEIGHT_STRING(a)=WEIGHT_STRING(a COLLATE utf8mb4_unicode_ci) AS is_400,
+ WEIGHT_STRING(a)=WEIGHT_STRING(a COLLATE utf8mb4_unicode_520_ci) AS is_520
+FROM t1
+ORDER BY a;
+SELECT COUNT(DISTINCT a) FROM t1;
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 WHERE a='a';
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 ORDER BY a;
+SELECT HEX(a), REPLACE(a,' ','<SP>') FROM t1 ORDER BY a DESC;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_ucs2_uca.test b/mysql-test/t/ctype_ucs2_uca.test
new file mode 100644
index 00000000000..bc6d6150ee6
--- /dev/null
+++ b/mysql-test/t/ctype_ucs2_uca.test
@@ -0,0 +1,21 @@
+-- source include/have_ucs2.inc
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-10877 xxx_unicode_nopad_ci collations
+--echo #
+SET NAMES utf8, character_set_connection=ucs2;
+let $coll='ucs2_unicode_nopad_ci';
+let $coll_pad='ucs2_unicode_ci';
+--source include/ctype_pad_all_engines.inc
+
+let $coll='ucs2_unicode_520_nopad_ci';
+let $coll_pad='ucs2_unicode_520_ci';
+--source include/ctype_pad_all_engines.inc
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf16_uca.test b/mysql-test/t/ctype_utf16_uca.test
index 160d5b19d12..95ce74076d0 100644
--- a/mysql-test/t/ctype_utf16_uca.test
+++ b/mysql-test/t/ctype_utf16_uca.test
@@ -221,3 +221,23 @@ SET collation_connection=utf16_thai_520_w2;
--echo #
--echo # End of 10.1 tests
--echo #
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-10877 xxx_unicode_nopad_ci collations
+--echo #
+SET NAMES utf8, character_set_connection=utf16;
+let $coll='utf16_unicode_nopad_ci';
+let $coll_pad='utf16_unicode_ci';
+--source include/ctype_pad_all_engines.inc
+
+let $coll='utf16_unicode_520_nopad_ci';
+let $coll_pad='utf16_unicode_520_ci';
+--source include/ctype_pad_all_engines.inc
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf32_uca.test b/mysql-test/t/ctype_utf32_uca.test
index fb691221db8..e5eb3b6d881 100644
--- a/mysql-test/t/ctype_utf32_uca.test
+++ b/mysql-test/t/ctype_utf32_uca.test
@@ -242,3 +242,24 @@ SET collation_connection=utf32_thai_520_w2;
--echo #
--echo # End of 10.1 tests
--echo #
+
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-10877 xxx_unicode_nopad_ci collations
+--echo #
+SET NAMES utf8, character_set_connection=utf32;
+let $coll='utf32_unicode_nopad_ci';
+let $coll_pad='utf32_unicode_ci';
+--source include/ctype_pad_all_engines.inc
+
+let $coll='utf32_unicode_520_nopad_ci';
+let $coll_pad='utf32_unicode_520_ci';
+--source include/ctype_pad_all_engines.inc
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8_uca.test b/mysql-test/t/ctype_utf8_uca.test
new file mode 100644
index 00000000000..670998a367b
--- /dev/null
+++ b/mysql-test/t/ctype_utf8_uca.test
@@ -0,0 +1,20 @@
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-10877 xxx_unicode_nopad_ci collations
+--echo #
+SET NAMES utf8;
+let $coll='utf8_unicode_nopad_ci';
+let $coll_pad='utf8_unicode_ci';
+--source include/ctype_pad_all_engines.inc
+
+let $coll='utf8_unicode_520_nopad_ci';
+let $coll_pad='utf8_unicode_520_ci';
+--source include/ctype_pad_all_engines.inc
+
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8mb4_uca.test b/mysql-test/t/ctype_utf8mb4_uca.test
index e56c6d7b884..fe76ed45e3f 100644
--- a/mysql-test/t/ctype_utf8mb4_uca.test
+++ b/mysql-test/t/ctype_utf8mb4_uca.test
@@ -83,3 +83,23 @@ SET collation_connection=utf8mb4_thai_520_w2;
--echo #
--echo # End of 10.1 tests
--echo #
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-9711 NO PAD Collatons
+--echo #
+SET NAMES utf8mb4;
+let $coll='utf8mb4_unicode_nopad_ci';
+let $coll_pad='utf8mb4_unicode_ci';
+--source include/ctype_pad_all_engines.inc
+
+let $coll='utf8mb4_unicode_520_nopad_ci';
+let $coll_pad='utf8mb4_unicode_520_ci';
+--source include/ctype_pad_all_engines.inc
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysys/charset-def.c b/mysys/charset-def.c
index 58fe16f353f..5c69a3046ec 100644
--- a/mysys/charset-def.c
+++ b/mysys/charset-def.c
@@ -50,6 +50,7 @@ extern struct charset_info_st my_charset_ucs2_vietnamese_ci;
extern struct charset_info_st my_charset_ucs2_croatian_uca_ci;
extern struct charset_info_st my_charset_ucs2_myanmar_uca_ci;
extern struct charset_info_st my_charset_ucs2_thai_520_w2;
+extern struct charset_info_st my_charset_ucs2_unicode_520_nopad_ci;
#endif
@@ -80,6 +81,7 @@ extern struct charset_info_st my_charset_utf32_vietnamese_ci;
extern struct charset_info_st my_charset_utf32_croatian_uca_ci;
extern struct charset_info_st my_charset_utf32_myanmar_uca_ci;
extern struct charset_info_st my_charset_utf32_thai_520_w2;
+extern struct charset_info_st my_charset_utf32_unicode_520_nopad_ci;
#endif /* HAVE_CHARSET_utf32 */
@@ -110,6 +112,7 @@ extern struct charset_info_st my_charset_utf16_vietnamese_ci;
extern struct charset_info_st my_charset_utf16_croatian_uca_ci;
extern struct charset_info_st my_charset_utf16_myanmar_uca_ci;
extern struct charset_info_st my_charset_utf16_thai_520_w2;
+extern struct charset_info_st my_charset_utf16_unicode_520_nopad_ci;
#endif /* HAVE_CHARSET_utf16 */
@@ -143,6 +146,7 @@ extern struct charset_info_st my_charset_utf8_thai_520_w2;
#ifdef HAVE_UTF8_GENERAL_CS
extern struct charset_info_st my_charset_utf8_general_cs;
#endif
+extern struct charset_info_st my_charset_utf8_unicode_520_nopad_ci;
#endif
#ifdef HAVE_CHARSET_utf8mb4
@@ -172,6 +176,7 @@ extern struct charset_info_st my_charset_utf8mb4_vietnamese_ci;
extern struct charset_info_st my_charset_utf8mb4_croatian_uca_ci;
extern struct charset_info_st my_charset_utf8mb4_myanmar_uca_ci;
extern struct charset_info_st my_charset_utf8mb4_thai_520_w2;
+extern struct charset_info_st my_charset_utf8mb4_unicode_520_nopad_ci;
#endif /* HAVE_CHARSET_utf8mb4 */
#endif /* HAVE_UCA_COLLATIONS */
@@ -287,6 +292,8 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_ucs2_croatian_uca_ci);
add_compiled_collation(&my_charset_ucs2_myanmar_uca_ci);
add_compiled_collation(&my_charset_ucs2_thai_520_w2);
+ add_compiled_collation(&my_charset_ucs2_unicode_nopad_ci);
+ add_compiled_collation(&my_charset_ucs2_unicode_520_nopad_ci);
#endif
#endif
@@ -334,6 +341,8 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf8_croatian_uca_ci);
add_compiled_collation(&my_charset_utf8_myanmar_uca_ci);
add_compiled_collation(&my_charset_utf8_thai_520_w2);
+ add_compiled_collation(&my_charset_utf8_unicode_nopad_ci);
+ add_compiled_collation(&my_charset_utf8_unicode_520_nopad_ci);
#endif
#endif /* HAVE_CHARSET_utf8 */
@@ -371,6 +380,8 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf8mb4_croatian_uca_ci);
add_compiled_collation(&my_charset_utf8mb4_myanmar_uca_ci);
add_compiled_collation(&my_charset_utf8mb4_thai_520_w2);
+ add_compiled_collation(&my_charset_utf8mb4_unicode_nopad_ci);
+ add_compiled_collation(&my_charset_utf8mb4_unicode_520_nopad_ci);
#endif /* HAVE_UCA_COLLATIONS */
#endif /* HAVE_CHARSET_utf8mb4 */
@@ -412,6 +423,8 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf16_croatian_uca_ci);
add_compiled_collation(&my_charset_utf16_myanmar_uca_ci);
add_compiled_collation(&my_charset_utf16_thai_520_w2);
+ add_compiled_collation(&my_charset_utf16_unicode_nopad_ci);
+ add_compiled_collation(&my_charset_utf16_unicode_520_nopad_ci);
#endif /* HAVE_UCA_COLLATIONS */
#endif /* HAVE_CHARSET_utf16 */
@@ -449,6 +462,8 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf32_croatian_uca_ci);
add_compiled_collation(&my_charset_utf32_myanmar_uca_ci);
add_compiled_collation(&my_charset_utf32_thai_520_w2);
+ add_compiled_collation(&my_charset_utf32_unicode_nopad_ci);
+ add_compiled_collation(&my_charset_utf32_unicode_520_nopad_ci);
#endif /* HAVE_UCA_COLLATIONS */
#endif /* HAVE_CHARSET_utf32 */
diff --git a/mysys/charset.c b/mysys/charset.c
index 2d9df9f47e4..016d0fc3012 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -310,14 +310,18 @@ static int add_collation(struct charset_info_st *cs)
if (!strcmp(cs->csname,"ucs2") )
{
#if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS)
- copy_uca_collation(newcs, &my_charset_ucs2_unicode_ci);
+ copy_uca_collation(newcs, newcs->state & MY_CS_NOPAD ?
+ &my_charset_ucs2_unicode_nopad_ci :
+ &my_charset_ucs2_unicode_ci);
newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII;
#endif
}
else if (!strcmp(cs->csname, "utf8") || !strcmp(cs->csname, "utf8mb3"))
{
#if defined (HAVE_CHARSET_utf8) && defined(HAVE_UCA_COLLATIONS)
- copy_uca_collation(newcs, &my_charset_utf8_unicode_ci);
+ copy_uca_collation(newcs, newcs->state & MY_CS_NOPAD ?
+ &my_charset_utf8_unicode_nopad_ci :
+ &my_charset_utf8_unicode_ci);
newcs->ctype= my_charset_utf8_unicode_ci.ctype;
if (init_state_maps(newcs))
return MY_XML_ERROR;
@@ -326,7 +330,9 @@ static int add_collation(struct charset_info_st *cs)
else if (!strcmp(cs->csname, "utf8mb4"))
{
#if defined (HAVE_CHARSET_utf8mb4) && defined(HAVE_UCA_COLLATIONS)
- copy_uca_collation(newcs, &my_charset_utf8mb4_unicode_ci);
+ copy_uca_collation(newcs, newcs->state & MY_CS_NOPAD ?
+ &my_charset_utf8mb4_unicode_nopad_ci :
+ &my_charset_utf8mb4_unicode_ci);
newcs->ctype= my_charset_utf8mb4_unicode_ci.ctype;
newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED;
#endif
@@ -334,14 +340,18 @@ static int add_collation(struct charset_info_st *cs)
else if (!strcmp(cs->csname, "utf16"))
{
#if defined (HAVE_CHARSET_utf16) && defined(HAVE_UCA_COLLATIONS)
- copy_uca_collation(newcs, &my_charset_utf16_unicode_ci);
+ copy_uca_collation(newcs, newcs->state & MY_CS_NOPAD ?
+ &my_charset_utf16_unicode_nopad_ci :
+ &my_charset_utf16_unicode_ci);
newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII;
#endif
}
else if (!strcmp(cs->csname, "utf32"))
{
#if defined (HAVE_CHARSET_utf32) && defined(HAVE_UCA_COLLATIONS)
- copy_uca_collation(newcs, &my_charset_utf32_unicode_ci);
+ copy_uca_collation(newcs, newcs->state & MY_CS_NOPAD ?
+ &my_charset_utf32_unicode_nopad_ci :
+ &my_charset_utf32_unicode_ci);
newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII;
#endif
}
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index a85c4f75408..73a813feed9 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -32088,36 +32088,119 @@ end:
}
+static void my_hash_sort_uca_nopad(CHARSET_INFO *cs,
+ my_uca_scanner_handler *scanner_handler,
+ const uchar *s, size_t slen,
+ ulong *nr1, ulong *nr2)
+{
+ int s_res;
+ my_uca_scanner scanner;
+ register ulong m1= *nr1, m2= *nr2;
+
+ scanner_handler->init(&scanner, cs, &cs->uca->level[0], s, slen);
+
+ while ((s_res= scanner_handler->next(&scanner)) >0)
+ {
+ /* See comment above why we can't use MY_HASH_ADD_16() */
+ MY_HASH_ADD(m1, m2, s_res >> 8);
+ MY_HASH_ADD(m1, m2, s_res & 0xFF);
+ }
+ *nr1= m1;
+ *nr2= m2;
+}
+
+
static uchar *
-my_strnxfrm_uca_onelevel(CHARSET_INFO *cs,
- my_uca_scanner_handler *scanner_handler,
- MY_UCA_WEIGHT_LEVEL *level,
- uchar *dst, uchar *de, uint nweights,
- const uchar *src, size_t srclen, uint flags)
+my_strnxfrm_uca_onelevel_internal(CHARSET_INFO *cs,
+ my_uca_scanner_handler *scanner_handler,
+ MY_UCA_WEIGHT_LEVEL *level,
+ uchar *dst, uchar *de, uint *nweights,
+ const uchar *src, size_t srclen)
{
my_uca_scanner scanner;
- uchar *d0= dst;
int s_res;
+ DBUG_ASSERT(src || !srclen);
+
scanner_handler->init(&scanner, cs, level, src, srclen);
- for (; dst < de && nweights &&
- (s_res= scanner_handler->next(&scanner)) > 0 ; nweights--)
+ for (; dst < de && *nweights &&
+ (s_res= scanner_handler->next(&scanner)) > 0 ; (*nweights)--)
{
*dst++= s_res >> 8;
if (dst < de)
*dst++= s_res & 0xFF;
}
+ return dst;
+}
- if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+
+static uchar *
+my_strnxfrm_uca_padn(uchar *dst, uchar *de, uint nweights, int weight)
+{
+ uint count= MY_MIN((uint) (de - dst) / 2, nweights);
+ for (; count ; count--)
{
- uint space_count= MY_MIN((uint) (de - dst) / 2, nweights);
- s_res= my_space_weight(level);
- for (; space_count ; space_count--)
- {
- *dst++= s_res >> 8;
- *dst++= s_res & 0xFF;
- }
+ *dst++= weight >> 8;
+ *dst++= weight & 0xFF;
+ }
+ return dst;
+}
+
+
+static uchar *
+my_strnxfrm_uca_pad(uchar *dst, uchar *de, int weight)
+{
+ for ( ; dst < de; )
+ {
+ *dst++= weight >> 8;
+ if (dst < de)
+ *dst++= weight & 0xFF;
}
+ return dst;
+}
+
+
+static uchar *
+my_strnxfrm_uca_onelevel(CHARSET_INFO *cs,
+ my_uca_scanner_handler *scanner_handler,
+ MY_UCA_WEIGHT_LEVEL *level,
+ uchar *dst, uchar *de, uint nweights,
+ const uchar *src, size_t srclen, uint flags)
+{
+ uchar *d0= dst;
+
+ dst= my_strnxfrm_uca_onelevel_internal(cs, scanner_handler, level,
+ dst, de, &nweights,
+ src, srclen);
+ DBUG_ASSERT(dst <= de);
+ if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+ dst= my_strnxfrm_uca_padn(dst, de, nweights, my_space_weight(level));
+ DBUG_ASSERT(dst <= de);
+ my_strxfrm_desc_and_reverse(d0, dst, flags, 0);
+ return dst;
+}
+
+
+static uchar *
+my_strnxfrm_uca_nopad_onelevel(CHARSET_INFO *cs,
+ my_uca_scanner_handler *scanner_handler,
+ MY_UCA_WEIGHT_LEVEL *level,
+ uchar *dst, uchar *de, uint nweights,
+ const uchar *src, size_t srclen, uint flags)
+{
+ uchar *d0= dst;
+
+ dst= my_strnxfrm_uca_onelevel_internal(cs, scanner_handler, level,
+ dst, de, &nweights,
+ src, srclen);
+ DBUG_ASSERT(dst <= de);
+ /*
+ Pad with the minimum possible primary weight 0x0200.
+ */
+ DBUG_ASSERT(level->levelno == 0); /* No multi-level NOPAD collations yet */
+ if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+ dst= my_strnxfrm_uca_padn(dst, de, nweights, 0x0200);
+ DBUG_ASSERT(dst <= de);
my_strxfrm_desc_and_reverse(d0, dst, flags, 0);
return dst;
}
@@ -32171,14 +32254,26 @@ my_strnxfrm_uca(CHARSET_INFO *cs,
like my_strnxfrm_uca_multilevel() does.
*/
if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && dst < de)
+ dst= my_strnxfrm_uca_pad(dst, de, my_space_weight(&cs->uca->level[0]));
+ return dst - d0;
+}
+
+
+static size_t
+my_strnxfrm_uca_nopad(CHARSET_INFO *cs,
+ my_uca_scanner_handler *scanner_handler,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags)
+{
+ uchar *d0= dst;
+ uchar *de= dst + dstlen;
+
+ dst= my_strnxfrm_uca_nopad_onelevel(cs, scanner_handler, &cs->uca->level[0],
+ dst, de, nweights, src, srclen, flags);
+ if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && dst < de)
{
- int s_res= my_space_weight(&cs->uca->level[0]);
- for ( ; dst < de; )
- {
- *dst++= s_res >> 8;
- if (dst < de)
- *dst++= s_res & 0xFF;
- }
+ memset(dst, 0, de - dst);
+ dst= de;
}
return dst - d0;
}
@@ -34286,6 +34381,16 @@ static int my_strnncollsp_any_uca(CHARSET_INFO *cs,
return my_strnncollsp_uca(cs, &my_any_uca_scanner_handler, s, slen, t, tlen);
}
+
+static int my_strnncollsp_generic_uca_nopad(CHARSET_INFO *cs,
+ const uchar *s, size_t slen,
+ const uchar *t, size_t tlen)
+{
+ return my_strnncoll_uca(cs, &my_any_uca_scanner_handler,
+ s, slen, t, tlen, FALSE);
+}
+
+
static int my_strnncollsp_any_uca_multilevel(CHARSET_INFO *cs,
const uchar *s, size_t slen,
const uchar *t, size_t tlen)
@@ -34301,6 +34406,13 @@ static void my_hash_sort_any_uca(CHARSET_INFO *cs,
my_hash_sort_uca(cs, &my_any_uca_scanner_handler, s, slen, n1, n2);
}
+static void my_hash_sort_generic_uca_nopad(CHARSET_INFO *cs,
+ const uchar *s, size_t slen,
+ ulong *n1, ulong *n2)
+{
+ my_hash_sort_uca_nopad(cs, &my_any_uca_scanner_handler, s, slen, n1, n2);
+}
+
static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags)
@@ -34309,6 +34421,16 @@ static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs,
dst, dstlen, nweights, src, srclen, flags);
}
+static size_t my_strnxfrm_generic_uca_nopad(CHARSET_INFO *cs,
+ uchar *dst, size_t dstlen,
+ uint nweights,
+ const uchar *src, size_t srclen,
+ uint flags)
+{
+ return my_strnxfrm_uca_nopad(cs, &my_any_uca_scanner_handler,
+ dst, dstlen, nweights, src, srclen, flags);
+}
+
static size_t my_strnxfrm_any_uca_multilevel(CHARSET_INFO *cs,
uchar *dst, size_t dstlen,
uint nweights, const uchar *src,
@@ -34331,6 +34453,40 @@ static size_t my_strnxfrmlen_any_uca_multilevel(CHARSET_INFO *cs, size_t len)
}
+/* NO PAD handler for character sets with mbminlen==1 */
+MY_COLLATION_HANDLER my_collation_mb_uca_nopad_handler =
+{
+ my_coll_init_uca,
+ my_strnncoll_any_uca,
+ my_strnncollsp_generic_uca_nopad,
+ my_strnxfrm_generic_uca_nopad,
+ my_strnxfrmlen_any_uca,
+ my_like_range_mb,
+ my_wildcmp_uca,
+ NULL,
+ my_instr_mb,
+ my_hash_sort_generic_uca_nopad,
+ my_propagate_complex
+};
+
+
+/* NO PAD handler for character sets with mbminlen>=1 */
+MY_COLLATION_HANDLER my_collation_generic_uca_nopad_handler =
+{
+ my_coll_init_uca,
+ my_strnncoll_any_uca,
+ my_strnncollsp_generic_uca_nopad,
+ my_strnxfrm_generic_uca_nopad,
+ my_strnxfrmlen_any_uca,
+ my_like_range_generic,
+ my_wildcmp_uca,
+ NULL,
+ my_instr_mb,
+ my_hash_sort_generic_uca_nopad,
+ my_propagate_complex
+};
+
+
MY_COLLATION_HANDLER my_collation_any_uca_handler_multilevel=
{
my_coll_init_uca_multilevel,
@@ -34397,7 +34553,9 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler =
my_propagate_complex
};
+
#define MY_CS_UCS2_UCA_FLAGS (MY_CS_COMMON_UCA_FLAGS|MY_CS_NONASCII)
+#define MY_CS_UCS2_UCA_NOPAD_FLAGS (MY_CS_UCS2_UCA_FLAGS|MY_CS_NOPAD)
struct charset_info_st my_charset_ucs2_unicode_ci=
{
@@ -35275,6 +35433,72 @@ struct charset_info_st my_charset_ucs2_vietnamese_ci=
};
+struct charset_info_st my_charset_ucs2_unicode_nopad_ci=
+{
+ MY_NOPAD_ID(128),0,0, /* number */
+ MY_CS_UCS2_UCA_NOPAD_FLAGS,/* state */
+ "ucs2", /* cs name */
+ "ucs2_unicode_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ NULL, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_default, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 2, /* mbminlen */
+ 2, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_ucs2_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
+struct charset_info_st my_charset_ucs2_unicode_520_nopad_ci=
+{
+ MY_NOPAD_ID(150),0,0, /* number */
+ MY_CS_UCS2_UCA_NOPAD_FLAGS, /* state */
+ "ucs2", /* cs name */
+ "ucs2_unicode_520_nopad_ci",/* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ &my_uca_v520, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_unicode520, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 2, /* mbminlen */
+ 2, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_ucs2_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
#endif
@@ -35294,6 +35518,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler =
my_propagate_complex
};
+
/*
We consider bytes with code more than 127 as a letter.
This garantees that word boundaries work fine with regular
@@ -35323,6 +35548,7 @@ static uchar ctype_utf8[] = {
extern MY_CHARSET_HANDLER my_charset_utf8_handler;
#define MY_CS_UTF8MB3_UCA_FLAGS MY_CS_COMMON_UCA_FLAGS
+#define MY_CS_UTF8MB3_UCA_NOPAD_FLAGS (MY_CS_UTF8MB3_UCA_FLAGS|MY_CS_NOPAD)
struct charset_info_st my_charset_utf8_unicode_ci=
{
@@ -36195,6 +36421,71 @@ struct charset_info_st my_charset_utf8_vietnamese_ci=
};
+struct charset_info_st my_charset_utf8_unicode_nopad_ci=
+{
+ MY_NOPAD_ID(192),0,0, /* number */
+ MY_CS_UTF8MB3_UCA_NOPAD_FLAGS, /* flags */
+ MY_UTF8MB3, /* cs name */
+ MY_UTF8MB3 "_unicode_nopad_ci",/* name */
+ "", /* comment */
+ "", /* tailoring */
+ ctype_utf8, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ NULL, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_default, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 1, /* mbminlen */
+ 3, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf8_handler,
+ &my_collation_mb_uca_nopad_handler
+};
+
+
+struct charset_info_st my_charset_utf8_unicode_520_nopad_ci=
+{
+ MY_NOPAD_ID(214),0,0, /* number */
+ MY_CS_UTF8MB3_UCA_NOPAD_FLAGS, /* flags */
+ MY_UTF8MB3, /* csname */
+ MY_UTF8MB3 "_unicode_520_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ ctype_utf8, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ &my_uca_v520, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_unicode520, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 1, /* mbminlen */
+ 3, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf8_handler,
+ &my_collation_mb_uca_nopad_handler
+};
+
#endif /* HAVE_CHARSET_utf8 */
@@ -36203,6 +36494,7 @@ struct charset_info_st my_charset_utf8_vietnamese_ci=
extern MY_CHARSET_HANDLER my_charset_utf8mb4_handler;
#define MY_CS_UTF8MB4_UCA_FLAGS (MY_CS_COMMON_UCA_FLAGS|MY_CS_UNICODE_SUPPLEMENT)
+#define MY_CS_UTF8MB4_UCA_NOPAD_FLAGS (MY_CS_UTF8MB4_UCA_FLAGS|MY_CS_NOPAD)
struct charset_info_st my_charset_utf8mb4_unicode_ci=
{
@@ -37074,6 +37366,72 @@ struct charset_info_st my_charset_utf8mb4_vietnamese_ci=
};
+struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci=
+{
+ MY_NOPAD_ID(224),0,0, /* number */
+ MY_CS_UTF8MB4_UCA_NOPAD_FLAGS, /* state */
+ MY_UTF8MB4, /* csname */
+ MY_UTF8MB4 "_unicode_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ ctype_utf8, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ NULL, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_default, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 1, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf8mb4_handler,
+ &my_collation_mb_uca_nopad_handler
+};
+
+
+struct charset_info_st my_charset_utf8mb4_unicode_520_nopad_ci=
+{
+ MY_NOPAD_ID(246),0,0, /* number */
+ MY_CS_UTF8MB4_UCA_NOPAD_FLAGS, /* flags */
+ MY_UTF8MB4, /* csname */
+ MY_UTF8MB4 "_unicode_520_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ ctype_utf8, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ &my_uca_v520, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_unicode520, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 1, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0x10FFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf8mb4_handler,
+ &my_collation_mb_uca_nopad_handler
+};
+
+
#endif /* HAVE_CHARSET_utf8mb4 */
@@ -37094,9 +37452,11 @@ MY_COLLATION_HANDLER my_collation_utf32_uca_handler =
my_propagate_complex
};
+
extern MY_CHARSET_HANDLER my_charset_utf32_handler;
#define MY_CS_UTF32_UCA_FLAGS (MY_CS_COMMON_UCA_FLAGS|MY_CS_NONASCII)
+#define MY_CS_UTF32_UCA_NOPAD_FLAGS (MY_CS_UTF32_UCA_FLAGS|MY_CS_NOPAD)
struct charset_info_st my_charset_utf32_unicode_ci=
{
@@ -37969,6 +38329,73 @@ struct charset_info_st my_charset_utf32_vietnamese_ci=
};
+struct charset_info_st my_charset_utf32_unicode_nopad_ci=
+{
+ MY_NOPAD_ID(160),0,0, /* number */
+ MY_CS_UTF32_UCA_NOPAD_FLAGS, /* state */
+ "utf32", /* csname */
+ "utf32_unicode_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ NULL, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_default, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 4, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf32_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
+struct charset_info_st my_charset_utf32_unicode_520_nopad_ci=
+{
+ MY_NOPAD_ID(182),0,0, /* number */
+ MY_CS_UTF32_UCA_NOPAD_FLAGS, /* state */
+ "utf32", /* csname */
+ "utf32_unicode_520_nopad_ci",/* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ &my_uca_v520, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_unicode520, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 4, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0x10FFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf32_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
+
#endif /* HAVE_CHARSET_utf32 */
@@ -37990,9 +38417,11 @@ MY_COLLATION_HANDLER my_collation_utf16_uca_handler =
my_propagate_complex
};
+
extern MY_CHARSET_HANDLER my_charset_utf16_handler;
#define MY_CS_UTF16_UCA_FLAGS (MY_CS_COMMON_UCA_FLAGS|MY_CS_NONASCII)
+#define MY_CS_UTF16_UCA_NOPAD_FLAGS (MY_CS_UTF16_UCA_FLAGS|MY_CS_NOPAD)
struct charset_info_st my_charset_utf16_unicode_ci=
{
@@ -38867,6 +39296,72 @@ struct charset_info_st my_charset_utf16_vietnamese_ci=
};
+struct charset_info_st my_charset_utf16_unicode_nopad_ci=
+{
+ MY_NOPAD_ID(101),0,0, /* number */
+ MY_CS_UTF16_UCA_NOPAD_FLAGS, /* state */
+ "utf16", /* csname */
+ "utf16_unicode_nopad_ci", /* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ NULL, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_default, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 2, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0xFFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf16_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
+struct charset_info_st my_charset_utf16_unicode_520_nopad_ci=
+{
+ MY_NOPAD_ID(123),0,0, /* number */
+ MY_CS_UTF16_UCA_NOPAD_FLAGS, /* state */
+ "utf16", /* csname */
+ "utf16_unicode_520_nopad_ci",/* name */
+ "", /* comment */
+ "", /* tailoring */
+ NULL, /* ctype */
+ NULL, /* to_lower */
+ NULL, /* to_upper */
+ NULL, /* sort_order */
+ &my_uca_v520, /* uca */
+ NULL, /* tab_to_uni */
+ NULL, /* tab_from_uni */
+ &my_unicase_unicode520, /* caseinfo */
+ NULL, /* state_map */
+ NULL, /* ident_map */
+ 8, /* strxfrm_multiply */
+ 1, /* caseup_multiply */
+ 1, /* casedn_multiply */
+ 2, /* mbminlen */
+ 4, /* mbmaxlen */
+ 9, /* min_sort_char */
+ 0x10FFFF, /* max_sort_char */
+ ' ', /* pad char */
+ 0, /* escape_with_backslash_is_dangerous */
+ 1, /* levels_for_order */
+ &my_charset_utf16_handler,
+ &my_collation_generic_uca_nopad_handler
+};
+
+
#endif /* HAVE_CHARSET_utf16 */