summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/long_unique_bugs.result15
-rw-r--r--mysql-test/main/long_unique_bugs.test19
-rw-r--r--sql/table.cc9
3 files changed, 41 insertions, 2 deletions
diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result
index 4ac056d8591..b3a1076804b 100644
--- a/mysql-test/main/long_unique_bugs.result
+++ b/mysql-test/main/long_unique_bugs.result
@@ -171,3 +171,18 @@ insert into t1(a,b) values(2,2);
insert into t1(a,b) values(2,3);
insert into t1(a,b) values(3,2);
drop table t1;
+CREATE TABLE t1 (
+a CHAR(128),
+b CHAR(128) AS (a),
+c DATETIME,
+UNIQUE(c,b(64))
+) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY COLUMN c VARCHAR(4096);
+drop table t1;
+CREATE TABLE t1 (
+a CHAR(128),
+b CHAR(128) AS (a),
+c varchar(5000),
+UNIQUE(c,b(64))
+) ENGINE=InnoDB;
+drop table t1;
diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test
index 7ae6401ccba..6257111b3fb 100644
--- a/mysql-test/main/long_unique_bugs.test
+++ b/mysql-test/main/long_unique_bugs.test
@@ -196,3 +196,22 @@ insert into t1(a,b) values(2,2);
insert into t1(a,b) values(2,3);
insert into t1(a,b) values(3,2);
drop table t1;
+
+#
+# MDEV-18888 Server crashes in Item_field::register_field_in_read_map upon MODIFY COLUMN
+#
+CREATE TABLE t1 (
+ a CHAR(128),
+ b CHAR(128) AS (a),
+ c DATETIME,
+ UNIQUE(c,b(64))
+) ENGINE=InnoDB;
+ALTER TABLE t1 MODIFY COLUMN c VARCHAR(4096);
+drop table t1;
+CREATE TABLE t1 (
+ a CHAR(128),
+ b CHAR(128) AS (a),
+ c varchar(5000),
+ UNIQUE(c,b(64))
+) ENGINE=InnoDB;
+drop table t1;
diff --git a/sql/table.cc b/sql/table.cc
index 011a2bb2c9a..92a18219b9f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -3708,9 +3708,14 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
for ( ; key_part < key_part_end; key_part++)
{
Field *field= key_part->field= outparam->field[key_part->fieldnr - 1];
-
+ /*
+ There's no need to create a prefix
+ Field for HA_KEY_ALG_LONG_HASH indexes, as they implement prefixing via
+ Iten_func_left anyway (see parse_vcol_defs())
+ */
if (field->key_length() != key_part->length &&
- !(field->flags & BLOB_FLAG))
+ !(field->flags & BLOB_FLAG) &&
+ key_info->algorithm != HA_KEY_ALG_LONG_HASH)
{
/*
We are using only a prefix of the column as a key: