Commit d46b3c99 authored by Aleksey Midenkov's avatar Aleksey Midenkov Committed by Marko Mäkelä

MDEV-17697 Broken versioning info after instant drop column

Closes #986
parent cb2f36d3
......@@ -124,5 +124,16 @@ alter table t add index idx(a), lock=none;
alter table t drop column s, drop column e;
alter table t drop system versioning, lock=none;
ERROR 0A000: LOCK=NONE is not supported. Reason: Not implemented for system-versioned operations. Try LOCK=SHARED
#
# MDEV-17697 Broken versioning info after instant drop column
#
set @@system_versioning_alter_history= keep;
create or replace table t1 (a int, b int) with system versioning;
insert into t1 values (1, 1);
alter table t1 drop column b, algorithm=instant;
alter table t1 drop system versioning;
create or replace table t1 (a int, b int) with system versioning;
insert into t1 values (1, 1);
alter table t1 drop system versioning;
drop database test;
create database test;
......@@ -148,5 +148,29 @@ alter table t drop column s, drop column e;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t drop system versioning, lock=none;
--echo #
--echo # MDEV-17697 Broken versioning info after instant drop column
--echo #
set @@system_versioning_alter_history= keep;
create or replace table t1 (a int, b int) with system versioning;
insert into t1 values (1, 1);
alter table t1 drop column b, algorithm=instant;
alter table t1 drop system versioning;
create or replace table t1 (a int, b int) with system versioning;
insert into t1 values (1, 1);
if ($have_debug) {
--disable_query_log
--disable_result_log
set debug_dbug='+d,ib_commit_inplace_fail_1';
--error ER_INTERNAL_ERROR
alter table t1 drop column b, algorithm=instant;
set debug_dbug= default;
--enable_query_log
--enable_result_log
}
alter table t1 drop system versioning;
drop database test;
create database test;
......@@ -538,6 +538,14 @@ inline bool dict_table_t::instant_column(const dict_table_t& table,
& ~(DATA_NOT_NULL | DATA_VERSIONED)));
DBUG_ASSERT(c.mtype == o->mtype);
DBUG_ASSERT(c.len >= o->len);
if (o->vers_sys_start()) {
ut_ad(o->ind == vers_start);
vers_start = i;
} else if (o->vers_sys_end()) {
ut_ad(o->ind == vers_end);
vers_end = i;
}
continue;
}
......@@ -786,6 +794,16 @@ inline void dict_table_t::rollback_instant(
n_v_def = n_v_cols = old_n_v_cols;
n_t_def = n_t_cols = n_cols + n_v_cols;
if (versioned()) {
for (unsigned i = 0; i < n_cols; ++i) {
if (cols[i].vers_sys_start()) {
vers_start = i;
} else if (cols[i].vers_sys_end()) {
vers_end = i;
}
}
}
index->fields = old_fields;
mtr.commit();
......@@ -4116,7 +4134,7 @@ innobase_build_col_map(
Alter_inplace_info* ha_alter_info,
const TABLE* altered_table,
const TABLE* table,
const dict_table_t* new_table,
dict_table_t* new_table,
const dict_table_t* old_table,
dtuple_t* defaults,
mem_heap_t* heap)
......@@ -4190,6 +4208,13 @@ innobase_build_col_map(
}
col_map[old_i - num_old_v] = i;
if (old_table->versioned()) {
if (old_i == old_table->vers_start) {
new_table->vers_start = i;
} else if (old_i == old_table->vers_end) {
new_table->vers_end = i;
}
}
goto found_col;
}
}
......
......@@ -618,7 +618,8 @@ struct dict_col_t{
ut_ad(mtype == DATA_INT || mtype == DATA_FIXBINARY);
return mtype == DATA_INT;
}
/** @return whether this is system versioned */
/** @return whether this user column (not row_start, row_end)
has System Versioning property */
bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
/** @return whether this is the system version start */
bool vers_sys_start() const
......
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