Commit 4923604e authored by Nikita Malyavin's avatar Nikita Malyavin Committed by Marko Mäkelä

MDEV-18865 Assertion `t->first->versioned_by_id()' failed in innodb_prepare_commit_versioned

Cause:
* row_start != 0 treated as it exists. Probably, possible row permutations had not been taken in mind.

Solution:
* Checking both row_start and row_end is correct, so versioned() function is used
parent 720e9bd5
......@@ -488,4 +488,13 @@ add column row_end bigint unsigned as row end,
add period for system_time(row_start,row_end),
with system versioning;
set autocommit= 1;
# MDEV-18865 Assertion `t->first->versioned_by_id()'
# failed in innodb_prepare_commit_versioned
create or replace table t (x int) engine=innodb;
insert into t values (0);
alter table t add `row_start` bigint unsigned as row start,
add `row_end` bigint unsigned as row end,
add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
create or replace database test;
......@@ -512,4 +512,16 @@ alter table t
with system versioning;
set autocommit= 1;
--echo # MDEV-18865 Assertion `t->first->versioned_by_id()'
--echo # failed in innodb_prepare_commit_versioned
create or replace table t (x int) engine=innodb;
insert into t values (0);
alter table t add `row_start` bigint unsigned as row start,
add `row_end` bigint unsigned as row end,
add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
create or replace database test;
......@@ -10905,6 +10905,9 @@ create_table_info_t::create_table_def()
heap = mem_heap_create(1000);
ut_d(bool have_vers_start = false);
ut_d(bool have_vers_end = false);
for (ulint i = 0, j = 0; j < n_cols; i++) {
Field* field = m_form->field[i];
ulint vers_row = 0;
......@@ -10912,8 +10915,10 @@ create_table_info_t::create_table_def()
if (m_form->versioned()) {
if (i == m_form->s->row_start_field) {
vers_row = DATA_VERS_START;
ut_d(have_vers_start = true);
} else if (i == m_form->s->row_end_field) {
vers_row = DATA_VERS_END;
ut_d(have_vers_end = true);
} else if (!(field->flags
& VERS_UPDATE_UNVERSIONED_FLAG)) {
vers_row = DATA_VERSIONED;
......@@ -11034,6 +11039,10 @@ create_table_info_t::create_table_def()
j++;
}
ut_ad(have_vers_start == have_vers_end);
ut_ad(table->versioned() == have_vers_start);
ut_ad(!table->versioned() || table->vers_start != table->vers_end);
if (num_v) {
for (ulint i = 0, j = 0; i < n_cols; i++) {
dict_v_col_t* v_col;
......
......@@ -1603,10 +1603,14 @@ struct dict_table_t {
/** Add the table definition to the data dictionary cache */
void add_to_cache();
/** @return whether the table is versioned.
It is assumed that both vers_start and vers_end set to 0
iff table is not versioned. In any other case,
these fields correspond to actual positions in cols[]. */
bool versioned() const { return vers_start || vers_end; }
bool versioned_by_id() const
{
return vers_start && cols[vers_start].mtype == DATA_INT;
return versioned() && cols[vers_start].mtype == DATA_INT;
}
void inc_fk_checks()
......
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