summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2014-04-25 17:10:25 +0400
committerAlexander Barkov <bar@mnogosearch.org>2014-04-25 17:10:25 +0400
commitfbfa0043279757b2860e846c82cbf55ab92af9b8 (patch)
tree931fad7c7ee8f9db15f7b46779eec9fb91287efa
parent64923bb653f908a6ea422a2d252011f93056f41c (diff)
downloadmariadb-git-fbfa0043279757b2860e846c82cbf55ab92af9b8.tar.gz
MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
-rw-r--r--mysql-test/include/ctype_filesort.inc22
-rw-r--r--mysql-test/r/ctype_big5.result102
-rw-r--r--mysql-test/r/ctype_cp1250_ch.result51
-rw-r--r--mysql-test/r/ctype_eucjpms.result102
-rw-r--r--mysql-test/r/ctype_euckr.result102
-rw-r--r--mysql-test/r/ctype_gb2312.result102
-rw-r--r--mysql-test/r/ctype_gbk.result102
-rw-r--r--mysql-test/r/ctype_latin1.result102
-rw-r--r--mysql-test/r/ctype_latin1_de.result51
-rw-r--r--mysql-test/r/ctype_sjis.result102
-rw-r--r--mysql-test/r/ctype_tis620.result102
-rw-r--r--mysql-test/r/ctype_uca.result51
-rw-r--r--mysql-test/r/ctype_ucs.result102
-rw-r--r--mysql-test/r/ctype_ujis.result102
-rw-r--r--mysql-test/r/ctype_utf16.result102
-rw-r--r--mysql-test/r/ctype_utf16_uca.result51
-rw-r--r--mysql-test/r/ctype_utf16le.result102
-rw-r--r--mysql-test/r/ctype_utf32.result102
-rw-r--r--mysql-test/r/ctype_utf32_uca.result51
-rw-r--r--mysql-test/r/ctype_utf8.result102
-rw-r--r--mysql-test/r/ctype_utf8mb4.result102
-rw-r--r--mysql-test/r/ctype_utf8mb4_heap.result102
-rw-r--r--mysql-test/r/ctype_utf8mb4_innodb.result102
-rw-r--r--mysql-test/r/ctype_utf8mb4_myisam.result102
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result102
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result102
-rw-r--r--sql/sql_yacc.yy5
-rw-r--r--strings/ctype-utf8.c2
28 files changed, 2322 insertions, 2 deletions
diff --git a/mysql-test/include/ctype_filesort.inc b/mysql-test/include/ctype_filesort.inc
index b1b7f21064d..f80637e5f88 100644
--- a/mysql-test/include/ctype_filesort.inc
+++ b/mysql-test/include/ctype_filesort.inc
@@ -24,3 +24,25 @@ INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 GROUP BY MID(CURRENT_USER,0) WITH ROLLUP;
SELECT * FROM t1 GROUP BY MID('test',0) WITH ROLLUP;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+--echo #
+SELECT @@collation_connection;
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index aaf7cc9a371..bff5b5a250e 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -120,6 +120,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+big5_chinese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -284,6 +335,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+big5_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result
index f7cfda49db1..cb2122020b2 100644
--- a/mysql-test/r/ctype_cp1250_ch.result
+++ b/mysql-test/r/ctype_cp1250_ch.result
@@ -280,6 +280,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
set global LC_MESSAGES=convert((@@global.log_bin_trust_function_creators)
using cp1250);
ERROR HY000: Unknown locale: '1'
diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result
index 8b56e5ceb24..813eae74cab 100644
--- a/mysql-test/r/ctype_eucjpms.result
+++ b/mysql-test/r/ctype_eucjpms.result
@@ -9826,6 +9826,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+eucjpms_japanese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -9870,6 +9921,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+eucjpms_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result
index 525f14946d7..92553aa4de6 100644
--- a/mysql-test/r/ctype_euckr.result
+++ b/mysql-test/r/ctype_euckr.result
@@ -120,6 +120,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+euckr_korean_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -204,6 +255,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+euckr_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result
index a625c0f08d3..af220466b9b 100644
--- a/mysql-test/r/ctype_gb2312.result
+++ b/mysql-test/r/ctype_gb2312.result
@@ -120,6 +120,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+gb2312_chinese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -285,6 +336,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+gb2312_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result
index 31d61a7e98a..f4d0136a34f 100644
--- a/mysql-test/r/ctype_gbk.result
+++ b/mysql-test/r/ctype_gbk.result
@@ -120,6 +120,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+gbk_chinese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -285,6 +336,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+gbk_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index b29e66b0a3f..d21570fb05f 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -335,6 +335,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+latin1_swedish_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
latin1_swedish_ci
@@ -399,6 +450,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+latin1_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
latin1_bin
diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result
index ceb0a65304b..d20a9c89349 100644
--- a/mysql-test/r/ctype_latin1_de.result
+++ b/mysql-test/r/ctype_latin1_de.result
@@ -343,6 +343,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+latin1_german2_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
"BEGIN ctype_german.inc"
drop table if exists t1;
create table t1 as select repeat(' ', 64) as s1;
diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result
index 0b9e893c9e8..ffeb8524c6e 100644
--- a/mysql-test/r/ctype_sjis.result
+++ b/mysql-test/r/ctype_sjis.result
@@ -98,6 +98,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+sjis_japanese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -201,6 +252,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+sjis_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result
index 70f58f91d38..08cf9f1a753 100644
--- a/mysql-test/r/ctype_tis620.result
+++ b/mysql-test/r/ctype_tis620.result
@@ -2964,6 +2964,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+tis620_thai_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
tis620_thai_ci
@@ -3091,6 +3142,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+tis620_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
tis620_bin
diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result
index f2b9843f4a7..c14ad3e0db3 100644
--- a/mysql-test/r/ctype_uca.result
+++ b/mysql-test/r/ctype_uca.result
@@ -5900,6 +5900,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8_unicode_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8_unicode_ci
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index ae3798e38fb..e36f783196e 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -761,6 +761,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+ucs2_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
ucs2_general_ci
@@ -959,6 +1010,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+ucs2_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
ucs2_bin
diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result
index aace88419fb..77145fe2eb0 100644
--- a/mysql-test/r/ctype_ujis.result
+++ b/mysql-test/r/ctype_ujis.result
@@ -2234,6 +2234,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+ujis_japanese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
@@ -2318,6 +2369,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+ujis_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
create table t1 engine=innodb select repeat('a',50) as c1;
alter table t1 add index(c1(5));
insert into t1 values ('abcdefg'),('abcde100'),('abcde110'),('abcde111');
diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result
index 5c75bc098e3..150700bf60d 100644
--- a/mysql-test/r/ctype_utf16.result
+++ b/mysql-test/r/ctype_utf16.result
@@ -600,6 +600,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf16_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf16_general_ci
@@ -647,6 +698,57 @@ i
1
DROP TABLE t1;
#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf16_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
+#
# Bug#55980 Character sets: supplementary character _bin ordering is wrong
#
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result
index 1cae0542549..a59d3dc07ff 100644
--- a/mysql-test/r/ctype_utf16_uca.result
+++ b/mysql-test/r/ctype_utf16_uca.result
@@ -2874,6 +2874,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf16_unicode_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf16_unicode_ci
diff --git a/mysql-test/r/ctype_utf16le.result b/mysql-test/r/ctype_utf16le.result
index baf3f4bb0f8..8098b0d1666 100644
--- a/mysql-test/r/ctype_utf16le.result
+++ b/mysql-test/r/ctype_utf16le.result
@@ -644,6 +644,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf16le_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf16le_general_ci
@@ -690,6 +741,57 @@ i
1
DROP TABLE t1;
#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf16le_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
+#
# Bug#55980 Character sets: supplementary character _bin ordering is wrong
#
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result
index b67de4d0051..214ec9f9b1d 100644
--- a/mysql-test/r/ctype_utf32.result
+++ b/mysql-test/r/ctype_utf32.result
@@ -599,6 +599,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf32_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf32_general_ci
@@ -646,6 +697,57 @@ i
1
DROP TABLE t1;
#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf32_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
+#
# Bug#55980 Character sets: supplementary character _bin ordering is wrong
#
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result
index a79103a687f..b77283f1ddb 100644
--- a/mysql-test/r/ctype_utf32_uca.result
+++ b/mysql-test/r/ctype_utf32_uca.result
@@ -2874,6 +2874,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf32_unicode_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf32_unicode_ci
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index bb3a9365793..b16d98a7a19 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -963,6 +963,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8_general_ci
@@ -1143,6 +1194,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8_bin
diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result
index 55d5c6eed86..0dc94e90454 100644
--- a/mysql-test/r/ctype_utf8mb4.result
+++ b/mysql-test/r/ctype_utf8mb4.result
@@ -963,6 +963,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_general_ci
@@ -1125,6 +1176,57 @@ i
1
DROP TABLE t1;
#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
+#
# Bug#55980 Character sets: supplementary character _bin ordering is wrong
#
CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
diff --git a/mysql-test/r/ctype_utf8mb4_heap.result b/mysql-test/r/ctype_utf8mb4_heap.result
index 18c8ec69f83..57d29a24fd0 100644
--- a/mysql-test/r/ctype_utf8mb4_heap.result
+++ b/mysql-test/r/ctype_utf8mb4_heap.result
@@ -902,6 +902,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_general_ci
@@ -1063,6 +1114,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_bin
diff --git a/mysql-test/r/ctype_utf8mb4_innodb.result b/mysql-test/r/ctype_utf8mb4_innodb.result
index 68986e28dea..ba03a3f66e6 100644
--- a/mysql-test/r/ctype_utf8mb4_innodb.result
+++ b/mysql-test/r/ctype_utf8mb4_innodb.result
@@ -963,6 +963,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_general_ci
@@ -1124,6 +1175,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_bin
diff --git a/mysql-test/r/ctype_utf8mb4_myisam.result b/mysql-test/r/ctype_utf8mb4_myisam.result
index 8a2de245093..c4ff8e0a882 100644
--- a/mysql-test/r/ctype_utf8mb4_myisam.result
+++ b/mysql-test/r/ctype_utf8mb4_myisam.result
@@ -963,6 +963,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_general_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_general_ci
@@ -1124,6 +1175,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+utf8mb4_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
select @@collation_connection;
@@collation_connection
utf8mb4_bin
diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
index 8bdad1813ea..a6d997f653a 100644
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
@@ -11435,6 +11435,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp932_japanese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -11479,6 +11530,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp932_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
index 8bdad1813ea..a6d997f653a 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
@@ -11435,6 +11435,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp932_japanese_ci
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -11479,6 +11530,57 @@ i
1
1
DROP TABLE t1;
+#
+# MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+#
+SELECT @@collation_connection;
+@@collation_connection
+cp932_bin
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+a
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+a
+m
+l
+k
+j
+i
+h
+g
+f
+e
+d
+c
+b
+a
+DROP TABLE t1;
CREATE TABLE t1 AS
SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index ceb4e247848..0de67297302 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -11305,7 +11305,10 @@ opt_limit_clause:
limit_clause:
LIMIT limit_options
{
- Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT);
+ SELECT_LEX *sel= Select;
+ if (!sel->select_limit->basic_const_item() ||
+ sel->select_limit->val_int() > 0)
+ Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT);
}
| LIMIT limit_options ROWS_SYM EXAMINED_SYM limit_rows_option
{
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index aba179b154c..96d5ea26a3c 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -5688,7 +5688,7 @@ struct charset_info_st my_charset_utf8_general_mysql500_ci=
struct charset_info_st my_charset_utf8_bin=
{
83,0,0, /* number */
- MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE, /* state */
+ MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_BINSORT|MY_CS_UNICODE, /* state */
"utf8", /* cs name */
"utf8_bin", /* name */
"", /* comment */