← Back to team overview

maria-developers team mailing list archive

Re: c1bf5766aed: MDEV-16490: It's possible to make a system versioned table without any versioning field

 

Hi, Nikita!

On Mar 27, Nikita Malyavin wrote:
> revision-id: c1bf5766aed (versioning-1.0.5-41-gc1bf5766aed)
> parent(s): 141a5b24843
> author: Nikita Malyavin <nikitamalyavin@xxxxxxxxx>
> committer: Nikita Malyavin <nikitamalyavin@xxxxxxxxx>
> timestamp: 2018-07-20 23:37:26 +1000
> message:
> 
> MDEV-16490: It's possible to make a system versioned table without any versioning field
> 
> * do not allow versioned table to be without versioned (non-system) fields
> * prohibit changing field versioning, when removing table versioning
> 
> diff --git a/sql/sql_table.cc b/sql/sql_table.cc
> index dbf400b53d7..ee4cf457f45 100644
> --- a/sql/sql_table.cc
> +++ b/sql/sql_table.cc
> @@ -8473,11 +8473,21 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
>      }
>    }
>  
> -  if (table->versioned() && !(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING) &&
> -      new_create_list.elements == VERSIONING_FIELDS)
> +  if (table->versioned())
>    {
> -    my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), table->s->table_name.str);
> -    goto err;
> +    uint versioned_fields= 0;
> +    field_it.rewind();
> +    while (Create_field *f= field_it++)
> +    {
> +      if (!(f->flags & VERS_UPDATE_UNVERSIONED_FLAG))
> +        versioned_fields++;
> +    }
> +    if (!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING) &&
> +        versioned_fields == VERSIONING_FIELDS)
> +    {
> +      my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), table->s->table_name.str);
> +      goto err;
> +    }

wouldn't that fit naturally into Vers_parse_info::fix_alter_info() ?

Regards,
Sergei
Chief Architect MariaDB
and security@xxxxxxxxxxx