← Back to team overview

maria-developers team mailing list archive

Re: 003abb6d9dc: MDEV-18799 Long unique does not work after failed alter table

 

Hi, Sachin!

On Mar 12, Sachin Setiya wrote:
> revision-id: 003abb6d9dc (mariadb-10.4.3-58-g003abb6d9dc)
> parent(s): e2f8f968785
> author: sachin <sachin.setiya@xxxxxxxxxxx>
> committer: sachin <sachin.setiya@xxxxxxxxxxx>
> timestamp: 2019-03-12 19:29:57 +0530
> message:
> 
> 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.
> 
> diff --git a/sql/sql_table.cc b/sql/sql_table.cc
> index e721a868124..2d86035b7fd 100644
> --- a/sql/sql_table.cc
> +++ b/sql/sql_table.cc
> @@ -7923,6 +7923,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
>    Field **f_ptr,*field;
>    MY_BITMAP *dropped_fields= NULL; // if it's NULL - no dropped fields
>    bool drop_period= false;
> +  bool long_hash_key= false;
>    DBUG_ENTER("mysql_prepare_alter_table");
>  
>    /*
> @@ -8299,10 +8300,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
>    */
>    for (uint i=0 ; i < table->s->keys ; i++,key_info++)
>    {
> +    long_hash_key= false;

better declare long_hash_key here, you don't use it on a larger scope.

>      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();
> @@ -8476,8 +8481,12 @@ 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;
> +      key_info->flags&= ~HA_NOSAME;

perhaps you could move HA_NOSAME manipulations into [re_]setup_keyinfo_hash ?

>        re_setup_keyinfo_hash(key_info);
> +    }
>    }
>    {
>      Key *key;
> 
Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx