1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-27293 Allow converting a versioned table from implicit

to explicit row_start/row_end columns

In case of adding both system fields of same type (length, unsigned
flag) as old implicit system fields do the rename of implicit system
fields to the ones specified in ALTER, remove SYSTEM_INVISIBLE flag in
that case. Correct PERIOD clause must be specified in ALTER as well.

MDEV-34904 Inplace alter for implicit to explicit versioning is broken

Whether ALTER goes inplace and how it goes inplace depends on
handler_flags which goes from alter_info->flags by this logic:

  ha_alter_info->handler_flags|= (alter_info->flags & ~flags_to_remove);

ALTER_VERS_EXPLICIT was not in flags_to_remove and its value (1ULL <<
35) clashed with ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX.

ALTER_VERS_EXPLICIT must not affect inplace, it is SQL-only so we
remove it from handler_flags.
This commit is contained in:
Aleksey Midenkov
2024-10-29 14:18:38 +03:00
parent 5e5c3c7cb6
commit cc183489da
10 changed files with 170 additions and 45 deletions

View File

@@ -6691,7 +6691,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table,
alter_table_operations flags_to_remove=
ALTER_ADD_INDEX | ALTER_DROP_INDEX | ALTER_PARSER_ADD_COLUMN |
ALTER_PARSER_DROP_COLUMN | ALTER_COLUMN_ORDER | ALTER_RENAME_COLUMN |
ALTER_CHANGE_COLUMN;
ALTER_CHANGE_COLUMN | ALTER_VERS_EXPLICIT;
if (!table->file->native_versioned())
flags_to_remove|= ALTER_COLUMN_UNVERSIONED;
@@ -8425,7 +8425,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
dropped_sys_vers_fields|= field->flags;
drop_it.remove();
}
else if (field->invisible < INVISIBLE_SYSTEM)
else if (field->invisible < INVISIBLE_SYSTEM ||
(alter_info->flags & ALTER_VERS_EXPLICIT))
{
/*
This field was not dropped and not changed, add it to the list
@@ -8440,12 +8441,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (field->field_name.streq(alter->name))
break;
}
if (alter && field->invisible < INVISIBLE_SYSTEM)
if (alter)
{
if (alter->is_rename())
{
def->change= Lex_ident_column(alter->name);
def->field_name= Lex_ident_column(alter->new_name);
if (vers_system_invisible)
def->invisible= VISIBLE;
column_rename_param.fields.push_back(def);
if (field->flags & VERS_ROW_START)
{