summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-12-08 13:19:19 +0400
committerAlexander Barkov <bar@mariadb.org>2017-12-08 13:19:19 +0400
commit0e5eef886ac281599da2caa24e0a560b4f889c7d (patch)
tree8cab5bd78a286bda2830e9c8f9ce8458dbf074d7
parentdfafe15abbd552ed487b2b0f7188db9303b1fa1f (diff)
downloadmariadb-git-0e5eef886ac281599da2caa24e0a560b4f889c7d.tar.gz
MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
-rw-r--r--mysql-test/include/ctype_like_range_mdev14350.inc14
-rw-r--r--mysql-test/r/ctype_latin1.result25
-rw-r--r--mysql-test/r/ctype_like_range.result45
-rw-r--r--mysql-test/r/ctype_ucs2_uca.result26
-rw-r--r--mysql-test/r/ctype_utf16_uca.result26
-rw-r--r--mysql-test/r/ctype_utf32_uca.result26
-rw-r--r--mysql-test/r/ctype_utf8_uca.result25
-rw-r--r--mysql-test/r/ctype_utf8mb4_uca.result26
-rw-r--r--mysql-test/t/ctype_latin1.test3
-rw-r--r--mysql-test/t/ctype_like_range.test40
-rw-r--r--mysql-test/t/ctype_ucs2_uca.test4
-rw-r--r--mysql-test/t/ctype_utf16_uca.test5
-rw-r--r--mysql-test/t/ctype_utf32_uca.test5
-rw-r--r--mysql-test/t/ctype_utf8_uca.test3
-rw-r--r--mysql-test/t/ctype_utf8mb4_uca.test5
-rw-r--r--strings/ctype-mb.c10
-rw-r--r--strings/ctype-simple.c4
17 files changed, 285 insertions, 7 deletions
diff --git a/mysql-test/include/ctype_like_range_mdev14350.inc b/mysql-test/include/ctype_like_range_mdev14350.inc
new file mode 100644
index 00000000000..89ecc0201cd
--- /dev/null
+++ b/mysql-test/include/ctype_like_range_mdev14350.inc
@@ -0,0 +1,14 @@
+--echo #
+--echo # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+--echo #
+
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index 0ca643f25fb..b60d711568c 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -8804,6 +8804,31 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES latin1;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) DEFAULT NULL,
+ `b` varchar(50) DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_like_range.result b/mysql-test/r/ctype_like_range.result
index f8032d0ae86..d8e621fd056 100644
--- a/mysql-test/r/ctype_like_range.result
+++ b/mysql-test/r/ctype_like_range.result
@@ -4430,5 +4430,50 @@ a_ 6100 61FF
a% 61000000000000000000 61FFFFFFFFFFFFFFFFFF
DROP TABLE t1;
#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 313131
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 313131
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 313131
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 313131
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 003100310031
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16 COLLATE utf16_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 003100310031
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32 COLLATE utf32_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+a HEX(LIKE_RANGE_MIN(a,200))
+111% 000000310000003100000031
+DROP TABLE t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_ucs2_uca.result b/mysql-test/r/ctype_ucs2_uca.result
index 48ec25b32e3..44a623842c6 100644
--- a/mysql-test/r/ctype_ucs2_uca.result
+++ b/mysql-test/r/ctype_ucs2_uca.result
@@ -559,6 +559,32 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES utf8, collation_connection=ucs2_unicode_520_nopad_ci;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) CHARACTER SET ucs2 COLLATE ucs2_unicode_520_nopad_ci DEFAULT NULL,
+ `b` varchar(50) CHARACTER SET ucs2 COLLATE ucs2_unicode_520_nopad_ci DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
+SET NAMES utf8;
#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result
index 1105225ed87..0cb9c4c74c1 100644
--- a/mysql-test/r/ctype_utf16_uca.result
+++ b/mysql-test/r/ctype_utf16_uca.result
@@ -7866,6 +7866,32 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES utf8, collation_connection=utf16_unicode_520_nopad_ci;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) CHARACTER SET utf16 COLLATE utf16_unicode_520_nopad_ci DEFAULT NULL,
+ `b` varchar(50) CHARACTER SET utf16 COLLATE utf16_unicode_520_nopad_ci DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
+SET NAMES utf8;
#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result
index 097da3d7c16..a112918c0c3 100644
--- a/mysql-test/r/ctype_utf32_uca.result
+++ b/mysql-test/r/ctype_utf32_uca.result
@@ -7886,6 +7886,32 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES utf8, collation_connection=utf32_unicode_520_nopad_ci;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) CHARACTER SET utf32 COLLATE utf32_unicode_520_nopad_ci DEFAULT NULL,
+ `b` varchar(50) CHARACTER SET utf32 COLLATE utf32_unicode_520_nopad_ci DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
+SET NAMES utf8;
#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_utf8_uca.result b/mysql-test/r/ctype_utf8_uca.result
index c8107da3b6f..23e9802b61a 100644
--- a/mysql-test/r/ctype_utf8_uca.result
+++ b/mysql-test/r/ctype_utf8_uca.result
@@ -559,6 +559,31 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES utf8 COLLATE utf8_unicode_nopad_ci;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ `b` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
#
# End of 10.2 tests
#
diff --git a/mysql-test/r/ctype_utf8mb4_uca.result b/mysql-test/r/ctype_utf8mb4_uca.result
index ca7f1a3d7d4..0712ca63abd 100644
--- a/mysql-test/r/ctype_utf8mb4_uca.result
+++ b/mysql-test/r/ctype_utf8mb4_uca.result
@@ -6576,6 +6576,32 @@ DROP TABLE t1;
# End of ctype_pad.inc
#
SET STORAGE_ENGINE=Default;
+SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci;
+#
+# MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+#
+CREATE OR REPLACE TABLE t1 AS SELECT SPACE(50) AS a, SPACE (50) AS b;
+ALTER TABLE t1 ADD KEY(a), ADD KEY(b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci DEFAULT NULL,
+ `b` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('111', '111');
+INSERT INTO t1 VALUES ('222', '222');
+INSERT INTO t1 VALUES ('333', '333');
+INSERT INTO t1 VALUES ('444', '444');
+SELECT * FROM t1 WHERE a LIKE '111%';
+a b
+111 111
+SELECT * FROM t1 IGNORE INDEX (a) WHERE a LIKE '111%';
+a b
+111 111
+DROP TABLE t1;
+SET NAMES utf8mb4;
#
# End of 10.2 tests
#
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index 8c51bfef2d8..31d4ff7f802 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -411,6 +411,9 @@ let $coll='latin1_nopad_bin';
let $coll_pad='latin1_bin';
--source include/ctype_pad_all_engines.inc
+SET NAMES latin1;
+--source include/ctype_like_range_mdev14350.inc
+
--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/t/ctype_like_range.test b/mysql-test/t/ctype_like_range.test
index e8784990d36..3055abe5f59 100644
--- a/mysql-test/t/ctype_like_range.test
+++ b/mysql-test/t/ctype_like_range.test
@@ -155,5 +155,45 @@ SELECT a, HEX(mn), HEX(mx) FROM t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-14350 Index use with collation utf8mb4_unicode_nopad_ci on LIKE pattern with wrong results
+--echo #
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16 COLLATE utf16_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32 COLLATE utf32_unicode_nopad_ci);
+INSERT INTO t1 VALUES ('111%');
+SELECT a, HEX(LIKE_RANGE_MIN(a,200)) FROM t1;
+DROP TABLE t1;
+
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/t/ctype_ucs2_uca.test b/mysql-test/t/ctype_ucs2_uca.test
index bc6d6150ee6..0aed0956f6c 100644
--- a/mysql-test/t/ctype_ucs2_uca.test
+++ b/mysql-test/t/ctype_ucs2_uca.test
@@ -16,6 +16,10 @@ let $coll='ucs2_unicode_520_nopad_ci';
let $coll_pad='ucs2_unicode_520_ci';
--source include/ctype_pad_all_engines.inc
+SET NAMES utf8, collation_connection=ucs2_unicode_520_nopad_ci;
+--source include/ctype_like_range_mdev14350.inc
+SET NAMES utf8;
+
--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 95ce74076d0..46d572fbe81 100644
--- a/mysql-test/t/ctype_utf16_uca.test
+++ b/mysql-test/t/ctype_utf16_uca.test
@@ -238,6 +238,11 @@ let $coll='utf16_unicode_520_nopad_ci';
let $coll_pad='utf16_unicode_520_ci';
--source include/ctype_pad_all_engines.inc
+SET NAMES utf8, collation_connection=utf16_unicode_520_nopad_ci;
+--source include/ctype_like_range_mdev14350.inc
+SET NAMES utf8;
+
+
--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 e5eb3b6d881..334d8fd1d48 100644
--- a/mysql-test/t/ctype_utf32_uca.test
+++ b/mysql-test/t/ctype_utf32_uca.test
@@ -260,6 +260,11 @@ let $coll='utf32_unicode_520_nopad_ci';
let $coll_pad='utf32_unicode_520_ci';
--source include/ctype_pad_all_engines.inc
+SET NAMES utf8, collation_connection=utf32_unicode_520_nopad_ci;
+--source include/ctype_like_range_mdev14350.inc
+SET NAMES utf8;
+
+
--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
index 670998a367b..0879b4d2810 100644
--- a/mysql-test/t/ctype_utf8_uca.test
+++ b/mysql-test/t/ctype_utf8_uca.test
@@ -14,6 +14,9 @@ let $coll='utf8_unicode_520_nopad_ci';
let $coll_pad='utf8_unicode_520_ci';
--source include/ctype_pad_all_engines.inc
+SET NAMES utf8 COLLATE utf8_unicode_nopad_ci;
+--source include/ctype_like_range_mdev14350.inc
+
--echo #
--echo # End of 10.2 tests
diff --git a/mysql-test/t/ctype_utf8mb4_uca.test b/mysql-test/t/ctype_utf8mb4_uca.test
index fe76ed45e3f..160cb48bad6 100644
--- a/mysql-test/t/ctype_utf8mb4_uca.test
+++ b/mysql-test/t/ctype_utf8mb4_uca.test
@@ -100,6 +100,11 @@ let $coll='utf8mb4_unicode_520_nopad_ci';
let $coll_pad='utf8mb4_unicode_520_ci';
--source include/ctype_pad_all_engines.inc
+SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci;
+--source include/ctype_like_range_mdev14350.inc
+SET NAMES utf8mb4;
+
+
--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index 9e476c23202..bfd533e6f98 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -799,9 +799,9 @@ fill_max_and_min:
'a\0\0... is the smallest possible string when we have space expand
a\ff\ff... is the biggest possible string
*/
- *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) :
- res_length);
- *max_length= res_length;
+ *min_length= (cs->state & (MY_CS_BINSORT | MY_CS_NOPAD)) ?
+ (size_t) (min_str - min_org) :
+ res_length;
/* Create min key */
do
{
@@ -1002,9 +1002,9 @@ my_like_range_generic(CHARSET_INFO *cs,
a\min\min... is the smallest possible string
a\max\max... is the biggest possible string
*/
- *min_length= ((cs->state & MY_CS_BINSORT) ?
+ *min_length= (cs->state & (MY_CS_BINSORT | MY_CS_NOPAD)) ?
(size_t) (min_str - min_org) :
- res_length);
+ res_length;
*max_length= res_length;
goto pad_min_max;
}
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index cf73f117f0f..fc5218caba1 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -1059,9 +1059,9 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
if (*ptr == w_many) /* '%' in SQL */
{
/* Calculate length of keys */
- *min_length= ((cs->state & MY_CS_BINSORT) ?
+ *min_length= (cs->state & (MY_CS_BINSORT | MY_CS_NOPAD)) ?
(size_t) (min_str - min_org) :
- res_length);
+ res_length;
*max_length= res_length;
do
{