diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 5de7566c8a3..716c343f9c4 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -57,3 +57,9 @@ create table t (b blob, unique(b)) engine=myisam; insert into t values ('foo'); replace into t values ('foo'); drop table t; +CREATE TABLE t1 (f INT, x BLOB, UNIQUE (x)); +INSERT INTO t1 VALUES (1,'foo'); +ALTER TABLE t1 DROP x, ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +UPDATE t1 SET x = 'bar'; +DROP TABLE t1; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 0246ea7962a..05a9bf83aa4 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -72,3 +72,13 @@ create table t (b blob, unique(b)) engine=myisam; insert into t values ('foo'); replace into t values ('foo'); drop table t; + +# +# MDEV-18790 Server crash in fields_in_hash_keyinfo after unsuccessful attempt to drop BLOB with long index +# +CREATE TABLE t1 (f INT, x BLOB, UNIQUE (x)); +INSERT INTO t1 VALUES (1,'foo'); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +ALTER TABLE t1 DROP x, ALGORITHM=INPLACE; +UPDATE t1 SET x = 'bar'; +DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 826484a4ef5..e35deb19c80 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8476,6 +8476,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, &key_parts, key_info->option_list, DDL_options()); new_key_list.push_back(key, thd->mem_root); } + if (key_info->algorithm == HA_KEY_ALG_LONG_HASH) + re_setup_keyinfo_hash(key_info); } { Key *key;