summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/create-index.result9
-rw-r--r--mysql-test/suite/innodb/t/create-index.test11
-rw-r--r--storage/innobase/handler/handler0alter.cc4
3 files changed, 22 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/create-index.result b/mysql-test/suite/innodb/r/create-index.result
new file mode 100644
index 00000000000..ad358a86329
--- /dev/null
+++ b/mysql-test/suite/innodb/r/create-index.result
@@ -0,0 +1,9 @@
+#
+# Bug #18010711 UNIQUE PREFIX INDEX ON BINARY COLUMN: FAILING
+# ASSERTION: FLEN == LEN
+#
+create table t1 (f1 binary(5)) engine=innodb;
+insert into t1 values ('w'), ('w');
+create unique index index_t1 on t1(f1(4));
+ERROR 23000: Duplicate entry 'w' for key 'index_t1'
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/create-index.test b/mysql-test/suite/innodb/t/create-index.test
new file mode 100644
index 00000000000..e1e5b856aca
--- /dev/null
+++ b/mysql-test/suite/innodb/t/create-index.test
@@ -0,0 +1,11 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # Bug #18010711 UNIQUE PREFIX INDEX ON BINARY COLUMN: FAILING
+--echo # ASSERTION: FLEN == LEN
+--echo #
+create table t1 (f1 binary(5)) engine=innodb;
+insert into t1 values ('w'), ('w');
+--error ER_DUP_ENTRY
+create unique index index_t1 on t1(f1(4));
+drop table t1;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index e4697319309..005f14a6f23 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -110,16 +110,16 @@ innobase_col_to_mysql(
/* These column types should never be shipped to MySQL. */
ut_ad(0);
- case DATA_FIXBINARY:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_DECIMAL:
/* Above are the valid column types for MySQL data. */
ut_ad(flen == len);
/* fall through */
+ case DATA_FIXBINARY:
case DATA_CHAR:
/* We may have flen > len when there is a shorter
- prefix on a CHAR column. */
+ prefix on the CHAR and BINARY column. */
ut_ad(flen >= len);
#else /* UNIV_DEBUG */
default: