summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/my_compare.h65
-rw-r--r--mysql-test/include/ctype_nopad_prefix_unique.inc6
-rw-r--r--mysql-test/include/ctype_utf8mb3_uca_char.inc54
-rw-r--r--mysql-test/main/ctype_utf8_uca.result141
-rw-r--r--mysql-test/main/ctype_utf8_uca.test8
-rw-r--r--mysql-test/suite/innodb/r/innodb_ctype_utf8.result84
-rw-r--r--mysql-test/suite/innodb/t/innodb_ctype_utf8.test17
-rw-r--r--mysql-test/suite/maria/ctype_utf8mb3_uca.result69
-rw-r--r--mysql-test/suite/maria/ctype_utf8mb3_uca.test12
-rw-r--r--mysys/my_compare.c38
-rw-r--r--storage/innobase/handler/ha_innodb.cc14
-rw-r--r--storage/maria/ma_check.c6
-rw-r--r--storage/maria/ma_ft_boolean_search.c31
-rw-r--r--storage/maria/ma_ft_nlq_search.c10
-rw-r--r--storage/maria/ma_ft_parser.c4
-rw-r--r--storage/maria/ma_ft_update.c8
-rw-r--r--storage/maria/ma_unique.c17
-rw-r--r--storage/maria/ma_write.c4
-rw-r--r--storage/myisam/ft_boolean_search.c28
-rw-r--r--storage/myisam/ft_nlq_search.c6
-rw-r--r--storage/myisam/ft_parser.c4
-rw-r--r--storage/myisam/ft_stopwords.c6
-rw-r--r--storage/myisam/ft_update.c8
-rw-r--r--storage/myisam/mi_check.c6
-rw-r--r--storage/myisam/mi_unique.c18
-rw-r--r--storage/myisam/mi_write.c2
26 files changed, 565 insertions, 101 deletions
diff --git a/include/my_compare.h b/include/my_compare.h
index 2274b666be6..a47af8f9834 100644
--- a/include/my_compare.h
+++ b/include/my_compare.h
@@ -110,8 +110,69 @@ static inline void set_rec_bits(uint16 bits, uchar *ptr, uchar ofs, uint len)
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
-extern int ha_compare_text(CHARSET_INFO *, const uchar *, size_t,
- const uchar *, size_t , my_bool);
+
+static inline int ha_compare_ft_text_full(CHARSET_INFO *charset_info,
+ const uchar *a, size_t a_length,
+ const uchar *b, size_t b_length)
+{
+ return charset_info->coll->strnncollsp(charset_info,
+ a, a_length,
+ b, b_length);
+}
+
+
+static inline int ha_compare_ft_text_prefix(CHARSET_INFO *charset_info,
+ const uchar *a, size_t a_length,
+ const uchar *b, size_t b_length)
+{
+ return charset_info->coll->strnncoll(charset_info,
+ a, a_length,
+ b, b_length,
+ TRUE/*b_is_prefix*/);
+}
+
+
+static inline int ha_compare_ft_text(CHARSET_INFO *charset_info,
+ const uchar *a, size_t a_length,
+ const uchar *b, size_t b_length,
+ my_bool part_key)
+{
+ if (!part_key)
+ return ha_compare_ft_text_full(charset_info, a, a_length, b, b_length);
+ return ha_compare_ft_text_prefix(charset_info, a, a_length, b, b_length);
+}
+
+
+static inline int ha_compare_char_varying(CHARSET_INFO *charset_info,
+ const uchar *a, size_t a_length,
+ const uchar *b, size_t b_length,
+ my_bool part_key)
+{
+ if (!part_key)
+ return charset_info->coll->strnncollsp(charset_info, a, a_length,
+ b, b_length);
+ return charset_info->coll->strnncoll(charset_info, a, a_length,
+ b, b_length, part_key);
+}
+
+
+static inline int ha_compare_char_fixed(CHARSET_INFO *charset_info,
+ const uchar *a, size_t a_length,
+ const uchar *b, size_t b_length,
+ size_t nchars,
+ my_bool part_key)
+{
+ if (!part_key)
+ return charset_info->coll->strnncollsp_nchars(charset_info,
+ a, a_length,
+ b, b_length,
+ nchars,
+ MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES);
+ return charset_info->coll->strnncoll(charset_info, a, a_length,
+ b, b_length, part_key);
+}
+
+
extern int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
const uchar *b, uint key_length, uint nextflag,
uint *diff_pos);
diff --git a/mysql-test/include/ctype_nopad_prefix_unique.inc b/mysql-test/include/ctype_nopad_prefix_unique.inc
index b25128e9fef..ec5bda0eb3a 100644
--- a/mysql-test/include/ctype_nopad_prefix_unique.inc
+++ b/mysql-test/include/ctype_nopad_prefix_unique.inc
@@ -58,11 +58,6 @@ DROP TABLE t1;
# CHAR
-# MyISAM is buggy on CHAR+BTREE+UNIQUE+PREFIX (see MDEV-30048), disable for now
-# Other engines work fine
-
-if (`SELECT UPPER(@@storage_engine) != 'MYISAM'`)
-{
EXECUTE IMMEDIATE REPLACE(
'CREATE TABLE t1 ( '
' a CHAR(20) COLLATE <COLLATION>,'
@@ -72,7 +67,6 @@ SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ss ');
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
DROP TABLE t1;
-}
EXECUTE IMMEDIATE REPLACE(
'CREATE TABLE t1 ( '
diff --git a/mysql-test/include/ctype_utf8mb3_uca_char.inc b/mysql-test/include/ctype_utf8mb3_uca_char.inc
new file mode 100644
index 00000000000..4540416a6ed
--- /dev/null
+++ b/mysql-test/include/ctype_utf8mb3_uca_char.inc
@@ -0,0 +1,54 @@
+--echo #
+--echo # MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB
+--echo #
+
+SET NAMES utf8mb3;
+
+#
+# Engines have different conditions based on the column size
+# determining when to use trailing space compressions in key values,
+# so let's test different column sizes for better coverage.
+#
+
+
+#
+# CHAR(10)
+#
+
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(2)));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+
+#
+# CHAR(120)
+#
+
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(100)));
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+--echo #
+
+CREATE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+DROP TABLE t1;
+SET big_tables=DEFAULT;
diff --git a/mysql-test/main/ctype_utf8_uca.result b/mysql-test/main/ctype_utf8_uca.result
index 2e22097e6ac..546e77f4280 100644
--- a/mysql-test/main/ctype_utf8_uca.result
+++ b/mysql-test/main/ctype_utf8_uca.result
@@ -832,6 +832,20 @@ DROP TABLE t1;
EXECUTE IMMEDIATE REPLACE(
'CREATE TABLE t1 ( '
' a CHAR(20) COLLATE <COLLATION>,'
+ 'UNIQUE(a(3)))',
+'<COLLATION>', @@collation_connection);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(20) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(3))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss ');
+INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
+DROP TABLE t1;
+EXECUTE IMMEDIATE REPLACE(
+'CREATE TABLE t1 ( '
+ ' a CHAR(20) COLLATE <COLLATION>,'
'UNIQUE(a(3)) USING HASH)',
'<COLLATION>', @@collation_connection);
SHOW CREATE TABLE t1;
@@ -906,6 +920,133 @@ INSERT INTO t1 VALUES ('ss ');
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
DROP TABLE t1;
SET STORAGE_ENGINE=DEFAULT;
+SET default_storage_engine=MyISAM;
+#
+# MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB
+#
+SET NAMES utf8mb3;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(2)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(2))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(100)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(100))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+#
+# MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+#
+CREATE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(100) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+c
+ss
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+c
+ss
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+SET default_storage_engine=MEMORY;
+#
+# MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB
+#
+SET NAMES utf8mb3;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(2)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(2))
+) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(100)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(100))
+) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+#
+# MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+#
+CREATE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(100) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+c
+ss
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+c
+ss
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+SET default_storage_engine=DEFAULT;
#
# End of 10.4 tests
#
diff --git a/mysql-test/main/ctype_utf8_uca.test b/mysql-test/main/ctype_utf8_uca.test
index 255390b5ce5..be6d5248329 100644
--- a/mysql-test/main/ctype_utf8_uca.test
+++ b/mysql-test/main/ctype_utf8_uca.test
@@ -65,6 +65,14 @@ SET STORAGE_ENGINE=HEAP;
SET STORAGE_ENGINE=DEFAULT;
+
+SET default_storage_engine=MyISAM;
+--source include/ctype_utf8mb3_uca_char.inc
+SET default_storage_engine=MEMORY;
+--source include/ctype_utf8mb3_uca_char.inc
+SET default_storage_engine=DEFAULT;
+
+
--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/suite/innodb/r/innodb_ctype_utf8.result b/mysql-test/suite/innodb/r/innodb_ctype_utf8.result
index ab193db6e75..9a9de76c62a 100644
--- a/mysql-test/suite/innodb/r/innodb_ctype_utf8.result
+++ b/mysql-test/suite/innodb/r/innodb_ctype_utf8.result
@@ -379,5 +379,89 @@ INSERT INTO t1 VALUES ('ss ');
INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/;
DROP TABLE t1;
#
+# MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB
+#
+SET NAMES utf8mb3;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(2)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(2))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(100)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(100))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+#
+# MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+#
+CREATE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(100) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+c
+ss
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+c
+ss
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+#
+# MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+#
+CREATE OR REPLACE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(100) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+c
+ss
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+c
+ss
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+#
# End 10.4 tests
#
diff --git a/mysql-test/suite/innodb/t/innodb_ctype_utf8.test b/mysql-test/suite/innodb/t/innodb_ctype_utf8.test
index 9bc6408e0e0..82b5e000890 100644
--- a/mysql-test/suite/innodb/t/innodb_ctype_utf8.test
+++ b/mysql-test/suite/innodb/t/innodb_ctype_utf8.test
@@ -32,6 +32,23 @@ let $coll_pad='utf8_bin';
SET NAMES utf8mb3 COLLATE utf8mb3_unicode_nopad_ci;
--source include/ctype_nopad_prefix_unique.inc
+--source include/ctype_utf8mb3_uca_char.inc
+
+--echo #
+--echo # MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+--echo #
+
+CREATE OR REPLACE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+
+
--echo #
--echo # End 10.4 tests
--echo #
diff --git a/mysql-test/suite/maria/ctype_utf8mb3_uca.result b/mysql-test/suite/maria/ctype_utf8mb3_uca.result
new file mode 100644
index 00000000000..aa4a216ed57
--- /dev/null
+++ b/mysql-test/suite/maria/ctype_utf8mb3_uca.result
@@ -0,0 +1,69 @@
+#
+# Start of 10.4 tests
+#
+SET default_storage_engine=Aria;
+#
+# MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB
+#
+SET NAMES utf8mb3;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(10) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(2)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(2))
+) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(120) COLLATE utf8mb3_unicode_nopad_ci, UNIQUE KEY(a(100)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(120) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL,
+ UNIQUE KEY `a` (`a`(100))
+) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1
+INSERT INTO t1 VALUES ('ss'),('ß');
+DROP TABLE t1;
+#
+# MDEV-30050 Inconsistent results of DISTINCT with NOPAD
+#
+CREATE TABLE t1 (c CHAR(100) COLLATE utf8mb3_unicode_nopad_ci);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(100) CHARACTER SET utf8 COLLATE utf8_unicode_nopad_ci DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1
+INSERT INTO t1 VALUES ('ss'),('ß');
+SET big_tables=0;
+SELECT DISTINCT c FROM t1;
+c
+ss
+SET big_tables=1;
+SELECT DISTINCT c FROM t1;
+c
+ss
+DROP TABLE t1;
+SET big_tables=DEFAULT;
+#
+# End of 10.4 tests
+#
diff --git a/mysql-test/suite/maria/ctype_utf8mb3_uca.test b/mysql-test/suite/maria/ctype_utf8mb3_uca.test
new file mode 100644
index 00000000000..21cec59008b
--- /dev/null
+++ b/mysql-test/suite/maria/ctype_utf8mb3_uca.test
@@ -0,0 +1,12 @@
+--source include/have_maria.inc
+
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+SET default_storage_engine=Aria;
+--source include/ctype_utf8mb3_uca_char.inc
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysys/my_compare.c b/mysys/my_compare.c
index 358cb77008e..ba94a704c17 100644
--- a/mysys/my_compare.c
+++ b/mysys/my_compare.c
@@ -20,16 +20,6 @@
#include <my_compare.h>
#include <my_sys.h>
-int ha_compare_text(CHARSET_INFO *charset_info, const uchar *a, size_t a_length,
- const uchar *b, size_t b_length, my_bool part_key)
-{
- if (!part_key)
- return charset_info->coll->strnncollsp(charset_info, a, a_length,
- b, b_length);
- return charset_info->coll->strnncoll(charset_info, a, a_length,
- b, b_length, part_key);
-}
-
static int compare_bin(const uchar *a, uint a_length,
const uchar *b, uint b_length,
@@ -183,9 +173,14 @@ int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
next_key_length=key_length-b_length-pack_length;
if (piks &&
- (flag=ha_compare_text(keyseg->charset,a,a_length,b,b_length,
- (my_bool) ((nextflag & SEARCH_PREFIX) &&
- next_key_length <= 0))))
+ (flag= ha_compare_char_fixed(keyseg->charset,
+ a, a_length,
+ b, b_length,
+ keyseg->length /
+ keyseg->charset->mbmaxlen,
+ (my_bool)
+ ((nextflag & SEARCH_PREFIX) &&
+ next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length;
b+=b_length;
@@ -195,9 +190,14 @@ int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
{
uint length=(uint) (end-a), a_length=length, b_length=length;
if (piks &&
- (flag= ha_compare_text(keyseg->charset, a, a_length, b, b_length,
- (my_bool) ((nextflag & SEARCH_PREFIX) &&
- next_key_length <= 0))))
+ (flag= ha_compare_char_fixed(keyseg->charset,
+ a, a_length,
+ b, b_length,
+ keyseg->length /
+ keyseg->charset->mbmaxlen,
+ (my_bool)
+ ((nextflag & SEARCH_PREFIX) &&
+ next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a=end;
b+=length;
@@ -242,7 +242,9 @@ int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
next_key_length=key_length-b_length-pack_length;
if (piks &&
- (flag= ha_compare_text(keyseg->charset,a,a_length,b,b_length,
+ (flag= ha_compare_char_varying(keyseg->charset,
+ a,a_length,
+ b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
@@ -260,7 +262,7 @@ int ha_key_cmp(HA_KEYSEG *keyseg, const uchar *a,
next_key_length=key_length-b_length-pack_length;
if (piks &&
- (flag=compare_bin(a,a_length,b,b_length,
+ (flag=compare_bin(a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0), 0)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index c4a23a95d85..335fdb84446 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -6749,9 +6749,9 @@ innobase_fts_text_cmp(
const fts_string_t* s1 = (const fts_string_t*) p1;
const fts_string_t* s2 = (const fts_string_t*) p2;
- return(ha_compare_text(
+ return(ha_compare_ft_text_full(
charset, s1->f_str, static_cast<uint>(s1->f_len),
- s2->f_str, static_cast<uint>(s2->f_len), 0));
+ s2->f_str, static_cast<uint>(s2->f_len)));
}
/******************************************************************//**
@@ -6772,9 +6772,9 @@ innobase_fts_text_case_cmp(
newlen = strlen((const char*) s2->f_str);
- return(ha_compare_text(
+ return(ha_compare_ft_text_full(
charset, s1->f_str, static_cast<uint>(s1->f_len),
- s2->f_str, static_cast<uint>(newlen), 0));
+ s2->f_str, static_cast<uint>(newlen)));
}
/******************************************************************//**
@@ -6819,11 +6819,11 @@ innobase_fts_text_cmp_prefix(
const fts_string_t* s2 = (const fts_string_t*) p2;
int result;
- result = ha_compare_text(
+ result = ha_compare_ft_text_prefix(
charset, s2->f_str, static_cast<uint>(s2->f_len),
- s1->f_str, static_cast<uint>(s1->f_len), 1);
+ s1->f_str, static_cast<uint>(s1->f_len));
- /* We switched s1, s2 position in ha_compare_text. So we need
+ /* We switched s1, s2 position in ha_compare_ft_text_prefix. So we need
to negate the result */
return(-result);
}
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index fec443dfc56..c0b8831305d 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -5680,9 +5680,9 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
}
get_key_full_length_rdonly(val_off, ft_buf->lastkey);
- if (ha_compare_text(sort_param->seg->charset,
- a+1,a_len-1,
- ft_buf->lastkey+1,val_off-1, 0)==0)
+ if (ha_compare_ft_text_full(sort_param->seg->charset,
+ a + 1, a_len - 1,
+ ft_buf->lastkey + 1, val_off - 1) == 0)
{
uchar *p;
if (!ft_buf->buf) /* store in second-level tree */
diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c
index 7fe6d8ca2cc..d19ec86685f 100644
--- a/storage/maria/ma_ft_boolean_search.c
+++ b/storage/maria/ma_ft_boolean_search.c
@@ -162,8 +162,8 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
{
/* ORDER BY word, ndepth */
- int i= ha_compare_text(cs, (uchar*) (*a)->word + 1,(*a)->len - 1,
- (uchar*) (*b)->word + 1,(*b)->len - 1, 0);
+ int i= ha_compare_ft_text_full(cs, (uchar*) (*a)->word + 1, (*a)->len - 1,
+ (uchar*) (*b)->word + 1, (*b)->len - 1);
if (!i)
i=CMP_NUM((*a)->ndepth, (*b)->ndepth);
return i;
@@ -403,13 +403,14 @@ static int _ft2_search_no_lock(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
if (!r && !ftbw->off)
{
- r= ha_compare_text(ftb->charset,
- info->last_key.data+1,
- info->last_key.data_length + info->last_key.ref_length-
- extra-1,
- (uchar*) ftbw->word+1,
- ftbw->len-1,
- (my_bool) (ftbw->flags & FTB_FLAG_TRUNC));
+ r= ha_compare_ft_text(ftb->charset,
+ info->last_key.data + 1,
+ info->last_key.data_length +
+ info->last_key.ref_length -
+ extra - 1,
+ (uchar*) ftbw->word + 1,
+ ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC));
}
if (r) /* not found */
@@ -899,9 +900,9 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
for (a= 0, b= ftb->queue.elements, c= (a+b)/2; b-a>1; c= (a+b)/2)
{
ftbw= ftb->list[c];
- if (ha_compare_text(ftb->charset, (uchar*)word, len,
- (uchar*)ftbw->word+1, ftbw->len-1,
- (my_bool)(ftbw->flags&FTB_FLAG_TRUNC)) < 0)
+ if (ha_compare_ft_text(ftb->charset, (uchar*) word, len,
+ (uchar*) ftbw->word + 1, ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC)) < 0)
b= c;
else
a= c;
@@ -926,9 +927,9 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
for (; c >= 0; c--)
{
ftbw= ftb->list[c];
- if (ha_compare_text(ftb->charset, (uchar*)word, len,
- (uchar*)ftbw->word + 1,ftbw->len - 1,
- (my_bool)(ftbw->flags & FTB_FLAG_TRUNC)))
+ if (ha_compare_ft_text(ftb->charset, (uchar*) word, len,
+ (uchar*)ftbw->word + 1, ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC)))
{
if (ftb->with_scan & FTB_FLAG_TRUNC)
continue;
diff --git a/storage/maria/ma_ft_nlq_search.c b/storage/maria/ma_ft_nlq_search.c
index f7aa3afec9a..8807b255722 100644
--- a/storage/maria/ma_ft_nlq_search.c
+++ b/storage/maria/ma_ft_nlq_search.c
@@ -111,11 +111,11 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
while (!r && gweight)
{
if (key.data_length &&
- ha_compare_text(aio->charset,
- info->last_key.data+1,
- info->last_key.data_length +
- info->last_key.ref_length - extra - 1,
- key.data+1, key.data_length-1, 0))
+ ha_compare_ft_text_full(aio->charset,
+ info->last_key.data + 1,
+ info->last_key.data_length +
+ info->last_key.ref_length - extra - 1,
+ key.data + 1, key.data_length - 1))
break;
if (subkeys.i < 0)
diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c
index dbad6c4e7f5..1be9f59c70c 100644
--- a/storage/maria/ma_ft_parser.c
+++ b/storage/maria/ma_ft_parser.c
@@ -33,8 +33,8 @@ typedef struct st_my_maria_ft_parser_param
static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2)
{
- return ha_compare_text(cs, (uchar*) w1->pos, w1->len,
- (uchar*) w2->pos, w2->len, 0);
+ return ha_compare_ft_text_full(cs, (uchar*) w1->pos, w1->len,
+ (uchar*) w2->pos, w2->len);
}
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
diff --git a/storage/maria/ma_ft_update.c b/storage/maria/ma_ft_update.c
index 8e1bf397c86..6d17a6e0c6a 100644
--- a/storage/maria/ma_ft_update.c
+++ b/storage/maria/ma_ft_update.c
@@ -185,8 +185,8 @@ int _ma_ft_cmp(MARIA_HA *info, uint keynr, const uchar *rec1, const uchar *rec2)
{
if ((ftsi1.pos != ftsi2.pos) &&
(!ftsi1.pos || !ftsi2.pos ||
- ha_compare_text(cs, ftsi1.pos,ftsi1.len,
- ftsi2.pos,ftsi2.len,0)))
+ ha_compare_ft_text_full(cs, ftsi1.pos, ftsi1.len,
+ ftsi2.pos, ftsi2.len)))
DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT);
}
DBUG_RETURN(GEE_THEY_ARE_ABSOLUTELY_IDENTICAL);
@@ -213,8 +213,8 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, uchar *keybuf,
error=0;
while(old_word->pos && new_word->pos)
{
- cmp= ha_compare_text(cs, (uchar*) old_word->pos,old_word->len,
- (uchar*) new_word->pos,new_word->len,0);
+ cmp= ha_compare_ft_text_full(cs, (uchar*) old_word->pos, old_word->len,
+ (uchar*) new_word->pos, new_word->len);
cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5);
if (cmp < 0 || cmp2)
diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c
index ce7967608b9..cb5c8b0833a 100644
--- a/storage/maria/ma_unique.c
+++ b/storage/maria/ma_unique.c
@@ -236,11 +236,20 @@ my_bool _ma_unique_comp(MARIA_UNIQUEDEF *def, const uchar *a, const uchar *b,
memcpy((void*) &pos_a, pos_a+keyseg->bit_start, sizeof(char*));
memcpy((void*) &pos_b, pos_b+keyseg->bit_start, sizeof(char*));
}
- if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 ||
- type == HA_KEYTYPE_VARTEXT2)
+ if (type == HA_KEYTYPE_TEXT)
+ {
+ if (ha_compare_char_fixed(keyseg->charset,
+ pos_a, a_length,
+ pos_b, b_length,
+ keyseg->length / keyseg->charset->mbmaxlen,
+ 0))
+ return 1;
+ }
+ else if (type == HA_KEYTYPE_VARTEXT1 ||
+ type == HA_KEYTYPE_VARTEXT2)
{
- if (ha_compare_text(keyseg->charset, pos_a, a_length,
- pos_b, b_length, 0))
+ if (ha_compare_char_varying(keyseg->charset, pos_a, a_length,
+ pos_b, b_length, 0))
return 1;
}
else
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 88486bca246..590d1735ffa 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -890,8 +890,8 @@ ChangeSet@1.2562, 2008-04-09 07:41:40+02:00, serg@janus.mylan +9 -0
get_key_length(alen,a);
DBUG_ASSERT(info->ft1_to_ft2==0);
if (alen == blen &&
- ha_compare_text(keyinfo->seg->charset, a, alen,
- b, blen, 0) == 0)
+ ha_compare_ft_text_full(keyinfo->seg->charset, a, alen,
+ b, blen) == 0)
{
/* Yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 406a9bbc951..70aba616264 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -162,8 +162,8 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
{
/* ORDER BY word, ndepth */
- int i= ha_compare_text(cs, (uchar*) (*a)->word + 1, (*a)->len - 1,
- (uchar*) (*b)->word + 1, (*b)->len - 1, 0);
+ int i= ha_compare_ft_text_full(cs, (uchar*) (*a)->word + 1, (*a)->len - 1,
+ (uchar*) (*b)->word + 1, (*b)->len - 1);
if (!i)
i= CMP_NUM((*a)->ndepth, (*b)->ndepth);
return i;
@@ -407,12 +407,12 @@ static int _ft2_search_no_lock(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
if (!r && !ftbw->off)
{
- r= ha_compare_text(ftb->charset,
- info->lastkey+1,
- info->lastkey_length-extra-1,
- (uchar*) ftbw->word+1,
- ftbw->len-1,
- (my_bool) (ftbw->flags & FTB_FLAG_TRUNC));
+ r= ha_compare_ft_text(ftb->charset,
+ info->lastkey + 1,
+ info->lastkey_length - extra - 1,
+ (uchar*) ftbw->word + 1,
+ ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC));
}
if (r) /* not found */
@@ -907,9 +907,9 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
for (a= 0, b= ftb->queue.elements, c= (a+b)/2; b-a>1; c= (a+b)/2)
{
ftbw= ftb->list[c];
- if (ha_compare_text(ftb->charset, (uchar*)word, len,
- (uchar*)ftbw->word+1, ftbw->len-1,
- (my_bool) (ftbw->flags & FTB_FLAG_TRUNC)) < 0)
+ if (ha_compare_ft_text(ftb->charset, (uchar*)word, len,
+ (uchar*)ftbw->word + 1, ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC)) < 0)
b= c;
else
a= c;
@@ -934,9 +934,9 @@ static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
for (; c >= 0; c--)
{
ftbw= ftb->list[c];
- if (ha_compare_text(ftb->charset, (uchar*)word, len,
- (uchar*)ftbw->word + 1,ftbw->len - 1,
- (my_bool)(ftbw->flags & FTB_FLAG_TRUNC)))
+ if (ha_compare_ft_text(ftb->charset, (uchar*) word, len,
+ (uchar*) ftbw->word + 1, ftbw->len - 1,
+ (my_bool) (ftbw->flags & FTB_FLAG_TRUNC)))
{
if (ftb->with_scan & FTB_FLAG_TRUNC)
continue;
diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c
index 3e433b71761..55c97f7c684 100644
--- a/storage/myisam/ft_nlq_search.c
+++ b/storage/myisam/ft_nlq_search.c
@@ -109,8 +109,10 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
{
if (keylen &&
- ha_compare_text(aio->charset,info->lastkey+1,
- info->lastkey_length-extra-1, keybuff+1,keylen-1,0))
+ ha_compare_ft_text_full(aio->charset,
+ info->lastkey + 1,
+ info->lastkey_length - extra - 1,
+ keybuff + 1, keylen - 1))
break;
if (subkeys.i < 0)
diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c
index bc50301fab2..f04ceeb904a 100644
--- a/storage/myisam/ft_parser.c
+++ b/storage/myisam/ft_parser.c
@@ -31,8 +31,8 @@ typedef struct st_my_ft_parser_param
static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2)
{
- return ha_compare_text(cs, (uchar*) w1->pos, w1->len,
- (uchar*) w2->pos, w2->len, 0);
+ return ha_compare_ft_text_full(cs, (uchar*) w1->pos, w1->len,
+ (uchar*) w2->pos, w2->len);
}
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c
index 3422a82a111..481928e6b09 100644
--- a/storage/myisam/ft_stopwords.c
+++ b/storage/myisam/ft_stopwords.c
@@ -33,9 +33,9 @@ static TREE *stopwords3=NULL;
static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)),
FT_STOPWORD *w1, FT_STOPWORD *w2)
{
- return ha_compare_text(ft_stopword_cs,
- (uchar *)w1->pos,w1->len,
- (uchar *)w2->pos,w2->len,0);
+ return ha_compare_ft_text_full(ft_stopword_cs,
+ (uchar *) w1->pos, w1->len,
+ (uchar *) w2->pos, w2->len);
}
static int FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action,
diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c
index 0c97a926746..e172b1c8809 100644
--- a/storage/myisam/ft_update.c
+++ b/storage/myisam/ft_update.c
@@ -181,8 +181,8 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const uchar *rec1, const uchar *rec2)
{
if ((ftsi1.pos != ftsi2.pos) &&
(!ftsi1.pos || !ftsi2.pos ||
- ha_compare_text(cs, (uchar*) ftsi1.pos,ftsi1.len,
- (uchar*) ftsi2.pos,ftsi2.len,0)))
+ ha_compare_ft_text_full(cs, (uchar*) ftsi1.pos, ftsi1.len,
+ (uchar*) ftsi2.pos, ftsi2.len)))
DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT);
}
DBUG_RETURN(GEE_THEY_ARE_ABSOLUTELY_IDENTICAL);
@@ -210,8 +210,8 @@ int _mi_ft_update(MI_INFO *info, uint keynr, uchar *keybuf,
error=0;
while(old_word->pos && new_word->pos)
{
- cmp= ha_compare_text(cs, (uchar*) old_word->pos,old_word->len,
- (uchar*) new_word->pos,new_word->len,0);
+ cmp= ha_compare_ft_text_full(cs, (uchar*) old_word->pos, old_word->len,
+ (uchar*) new_word->pos, new_word->len);
cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5);
if (cmp < 0 || cmp2)
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index baca24eb56f..63b4802cf28 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -3957,9 +3957,9 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a)
}
get_key_full_length_rdonly(val_off, ft_buf->lastkey);
- if (ha_compare_text(sort_param->seg->charset,
- ((uchar *)a)+1,a_len-1,
- (uchar*) ft_buf->lastkey+1,val_off-1, 0)==0)
+ if (ha_compare_ft_text_full(sort_param->seg->charset,
+ ((uchar *)a) + 1, a_len - 1,
+ (uchar*) ft_buf->lastkey + 1, val_off - 1) == 0)
{
if (!ft_buf->buf) /* store in second-level tree */
{
diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c
index 5d16efb96a1..d267ca481bf 100644
--- a/storage/myisam/mi_unique.c
+++ b/storage/myisam/mi_unique.c
@@ -211,11 +211,21 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b,
memcpy((char**) &pos_a, pos_a+keyseg->bit_start, sizeof(char*));
memcpy((char**) &pos_b, pos_b+keyseg->bit_start, sizeof(char*));
}
- if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 ||
- type == HA_KEYTYPE_VARTEXT2)
+ if (type == HA_KEYTYPE_TEXT)
+ {
+ if (ha_compare_char_fixed(keyseg->charset,
+ (uchar *) pos_a, a_length,
+ (uchar *) pos_b, b_length,
+ keyseg->length / keyseg->charset->mbmaxlen,
+ 0))
+ return 1;
+ }
+ else if (type == HA_KEYTYPE_VARTEXT1 ||
+ type == HA_KEYTYPE_VARTEXT2)
{
- if (ha_compare_text(keyseg->charset, (uchar *) pos_a, a_length,
- (uchar *) pos_b, b_length, 0))
+ if (ha_compare_char_varying(keyseg->charset,
+ (uchar *) pos_a, a_length,
+ (uchar *) pos_b, b_length, 0))
return 1;
}
else
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index 7345ab1604d..5b909e3a410 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -542,7 +542,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
get_key_length(alen,a);
DBUG_ASSERT(info->ft1_to_ft2==0);
if (alen == blen &&
- ha_compare_text(keyinfo->seg->charset, a, alen, b, blen, 0)==0)
+ ha_compare_ft_text_full(keyinfo->seg->charset, a, alen, b, blen) == 0)
{
/* yup. converting */
info->ft1_to_ft2=(DYNAMIC_ARRAY *)