Commit 28461fe5 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute

cleanup

change_fields_versioning_try(): use innodb_col_no() instead of a manual loop

change_fields_versioning_cache(): use innodb_col_no() instead of a manual loop
parent c43d11b9
...@@ -8491,36 +8491,17 @@ change_fields_versioning_try( ...@@ -8491,36 +8491,17 @@ change_fields_versioning_try(
DBUG_RETURN(false); DBUG_RETURN(false);
} }
uint virtual_count = 0;
List_iterator_fast<Create_field> it( List_iterator_fast<Create_field> it(
ha_alter_info->alter_info->create_list); ha_alter_info->alter_info->create_list);
for (uint i = 0; i < table->s->fields; i++) { while (const Create_field* create_field = it++) {
const Field* field = table->field[i];
if (innobase_is_v_fld(field)) {
virtual_count++;
continue;
}
const Create_field* create_field = NULL;
while (const Create_field* cf = it++) {
if (cf->field == field) {
create_field = cf;
break;
}
}
it.rewind();
DBUG_ASSERT(create_field);
if (create_field->versioning if (create_field->versioning
== Column_definition::VERSIONING_NOT_SET) { == Column_definition::VERSIONING_NOT_SET) {
continue; continue;
} }
const dict_table_t* new_table = ctx->new_table; const dict_table_t* new_table = ctx->new_table;
ulint pos = i - virtual_count; const uint pos = innodb_col_no(create_field->field);
const dict_col_t* col = dict_table_get_nth_col(new_table, pos); const dict_col_t* col = dict_table_get_nth_col(new_table, pos);
DBUG_ASSERT(!col->vers_sys_start()); DBUG_ASSERT(!col->vers_sys_start());
...@@ -8560,31 +8541,12 @@ change_fields_versioning_cache( ...@@ -8560,31 +8541,12 @@ change_fields_versioning_cache(
DBUG_ASSERT(ctx); DBUG_ASSERT(ctx);
DBUG_ASSERT(ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED); DBUG_ASSERT(ha_alter_info->handler_flags & ALTER_COLUMN_UNVERSIONED);
uint virtual_count = 0;
List_iterator_fast<Create_field> it( List_iterator_fast<Create_field> it(
ha_alter_info->alter_info->create_list); ha_alter_info->alter_info->create_list);
for (uint i = 0; i < table->s->fields; i++) { while (const Create_field* create_field = it++) {
const Field* field = table->field[i]; dict_col_t* col = dict_table_get_nth_col(
ctx->new_table, innodb_col_no(create_field->field));
if (innobase_is_v_fld(field)) {
virtual_count++;
continue;
}
const Create_field* create_field = NULL;
while (const Create_field* cf = it++) {
if (cf->field == field) {
create_field = cf;
break;
}
}
it.rewind();
DBUG_ASSERT(create_field);
dict_col_t* col
= dict_table_get_nth_col(ctx->new_table, i - virtual_count);
if (create_field->versioning if (create_field->versioning
== Column_definition::WITHOUT_VERSIONING) { == Column_definition::WITHOUT_VERSIONING) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment