1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-18799 Long unique does not work after failed alter table

Restore table->key_info after calling setup_keyinfo_hash in
mysql_prepare_alter_table.
This commit is contained in:
sachin
2019-03-03 17:56:48 +05:30
committed by sachinsetia1001@gmail.com
parent c3cfcd5b5e
commit 560598c9b2
4 changed files with 43 additions and 4 deletions

View File

@ -8299,10 +8299,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
*/
for (uint i=0 ; i < table->s->keys ; i++,key_info++)
{
bool long_hash_key= false;
if (key_info->flags & HA_INVISIBLE_KEY)
continue;
if (key_info->algorithm == HA_KEY_ALG_LONG_HASH)
{
setup_keyinfo_hash(key_info);
long_hash_key= true;
}
const char *key_name= key_info->name.str;
Alter_drop *drop;
drop_it.rewind();
@ -8427,10 +8431,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
LEX_CSTRING tmp_name;
bzero((char*) &key_create_info, sizeof(key_create_info));
if (key_info->algorithm == HA_KEY_ALG_LONG_HASH)
{
key_info->flags|= HA_NOSAME;
key_info->algorithm= HA_KEY_ALG_UNDEF;
}
key_create_info.algorithm= key_info->algorithm;
/*
We copy block size directly as some engines, like Area, sets this
@ -8476,8 +8477,11 @@ 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)
if (long_hash_key)
{
key_info->algorithm= HA_KEY_ALG_LONG_HASH;
re_setup_keyinfo_hash(key_info);
}
}
{
Key *key;