1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

SQL: prohibit column conversion to system fields for non-empty table [fixes #310]

This commit is contained in:
Eugene Kosov
2017-11-20 18:34:25 +03:00
committed by Aleksey Midenkov
parent 00b98264a8
commit 91ba4f04be
6 changed files with 58 additions and 3 deletions

View File

@ -6913,8 +6913,9 @@ static bool add_field_to_drop_list(THD *thd, Alter_info *alter_info,
bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
HA_CREATE_INFO *create_info,
TABLE_SHARE *share)
TABLE *table)
{
TABLE_SHARE *share= table->s;
bool integer_fields=
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING;
const char *table_name= share->table_name.str;
@ -6950,6 +6951,29 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
return false;
}
{
List_iterator_fast<Create_field> it(alter_info->create_list);
while (Create_field *f= it++)
{
if (f->change.length &&
f->flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG))
{
if (thd->mdl_context.upgrade_shared_lock(
table->mdl_ticket, MDL_EXCLUSIVE,
thd->variables.lock_wait_timeout))
return true;
if (table->file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME))
return true;
if (0 < table->file->records())
{
my_error(ER_VERS_GENERATED_ALWAYS_NOT_EMPTY, MYF(0), f->change.str);
return true;
}
break;
}
}
}
if ((versioned_fields || unversioned_fields) && !share->versioned)
{
my_error_as(ER_VERS_WRONG_PARAMS, ER_VERS_NOT_VERSIONED, MYF(0), table_name);