1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-11 05:52:26 +03:00

ALTER TABLE ... DROP COLUMN sys_start

update all unique keys, not just PK
This commit is contained in:
Sergei Golubchik
2018-02-09 17:30:20 +01:00
parent dfd42ed990
commit 4fd48678ae
4 changed files with 30 additions and 64 deletions

View File

@@ -7135,29 +7135,6 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
return false;
}
static bool is_dropping_primary_key(Alter_info *alter_info)
{
List_iterator_fast<Alter_drop> it(alter_info->drop_list);
while (Alter_drop *ad= it++)
{
if (ad->type == Alter_drop::KEY &&
!my_strcasecmp(system_charset_info, ad->name, primary_key_name))
return true;
}
return false;
}
static bool is_adding_primary_key(Alter_info *alter_info)
{
List_iterator_fast<Key> it(alter_info->key_list);
while (Key *key= it++)
{
if (key->type == Key::PRIMARY)
return true;
}
return false;
}
bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
HA_CREATE_INFO *create_info, TABLE *table)
{
@@ -7188,42 +7165,6 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return true;
}
if (share->primary_key != MAX_KEY && !is_adding_primary_key(alter_info) &&
!is_dropping_primary_key(alter_info))
{
alter_info->flags|= Alter_info::ALTER_DROP_INDEX;
Alter_drop *ad= new (thd->mem_root)
Alter_drop(Alter_drop::KEY, primary_key_name, false);
if (!ad || alter_info->drop_list.push_back(ad, thd->mem_root))
return true;
alter_info->flags|= Alter_info::ALTER_ADD_INDEX;
LEX_CSTRING key_name= {NULL, 0};
DDL_options_st options;
options.init();
Key *pk= new (thd->mem_root)
Key(Key::PRIMARY, &key_name, HA_KEY_ALG_UNDEF, false, options);
if (!pk)
return true;
st_key &key= table->key_info[share->primary_key];
for (st_key_part_info *it= key.key_part,
*end= it + key.user_defined_key_parts;
it != end; ++it)
{
if (it->field->vers_sys_field())
continue;
Key_part_spec *key_part_spec= new (thd->mem_root)
Key_part_spec(&it->field->field_name, it->length);
if (!key_part_spec ||
pk->columns.push_back(key_part_spec, thd->mem_root))
return true;
}
alter_info->key_list.push_back(pk);
}
return false;
}